From 79a07bae4d2f320d3105ac51b93ff067cec8b2ad Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 1 Nov 2023 18:40:16 -0400 Subject: [PATCH] Prototype using GetOpt rather than docopt --- composer.json | 4 +- composer.lock | 154 ++++++------ lib/CLI.php | 100 +++++--- vendor-bin/csfixer/composer.lock | 403 ++++++++----------------------- vendor-bin/daux/composer.lock | 257 ++++++++++---------- vendor-bin/phpstan/composer.json | 1 + vendor-bin/phpstan/composer.lock | 18 ++ vendor-bin/phpunit/composer.lock | 55 +++-- vendor-bin/robo/composer.lock | 169 ++++++------- 9 files changed, 505 insertions(+), 656 deletions(-) create mode 100644 vendor-bin/phpstan/composer.json create mode 100644 vendor-bin/phpstan/composer.lock diff --git a/composer.json b/composer.json index 5a6a8ad8..8df20c41 100644 --- a/composer.json +++ b/composer.json @@ -26,10 +26,10 @@ "ext-dom": "*", "nicolus/picofeed": "dev-patch-3", "hosteurope/password-generator": "1.*", - "docopt/docopt": "1.*", "jkingweb/druuid": "3.*", "guzzlehttp/psr7": "2.*", - "laminas/laminas-httphandlerrunner": "2.*" + "laminas/laminas-httphandlerrunner": "2.*", + "ulrichsg/getopt-php": "^4.0" }, "require-dev": { "bamarni/composer-bin-plugin": "*" diff --git a/composer.lock b/composer.lock index 6f7f738f..28358b8c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,73 +4,26 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8d22dd66c6cde0b1ed4ca0009293bf88", + "content-hash": "bfac70a85f90c472b42fc3d22c4e9f45", "packages": [ - { - "name": "docopt/docopt", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/docopt/docopt.php.git", - "reference": "0e3db660cf2f2eb07a83253790b7d97cdb398826" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/docopt/docopt.php/zipball/0e3db660cf2f2eb07a83253790b7d97cdb398826", - "reference": "0e3db660cf2f2eb07a83253790b7d97cdb398826", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/docopt.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Blake Williams", - "email": "code@shabbyrobe.org", - "homepage": "http://docopt.org/", - "role": "Developer" - } - ], - "description": "Port of Python's docopt for PHP >=5.3", - "homepage": "http://github.com/docopt/docopt.php", - "keywords": [ - "cli", - "docs" - ], - "support": { - "issues": "https://github.com/docopt/docopt.php/issues", - "source": "https://github.com/docopt/docopt.php/tree/1.0.5" - }, - "time": "2023-03-22T12:31:48+00:00" - }, { "name": "guzzlehttp/guzzle", - "version": "7.7.0", + "version": "7.8.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" + "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1110f66a6530a40fe7aea0378fe608ee2b2248f9", + "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0", - "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "guzzlehttp/promises": "^1.5.3 || ^2.0.1", + "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -161,7 +114,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.7.0" + "source": "https://github.com/guzzle/guzzle/tree/7.8.0" }, "funding": [ { @@ -177,20 +130,20 @@ "type": "tidelift" } ], - "time": "2023-05-21T14:04:53+00:00" + "time": "2023-08-27T10:20:53+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6" + "reference": "111166291a0f8130081195ac4556a5587d7f1b5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6", - "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d", + "reference": "111166291a0f8130081195ac4556a5587d7f1b5d", "shasum": "" }, "require": { @@ -244,7 +197,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.0" + "source": "https://github.com/guzzle/promises/tree/2.0.1" }, "funding": [ { @@ -260,20 +213,20 @@ "type": "tidelift" } ], - "time": "2023-05-21T13:50:22+00:00" + "time": "2023-08-03T15:11:55+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.5.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6" + "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/be45764272e8873c72dbe3d2edcfdfcc3bc9f727", + "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727", "shasum": "" }, "require": { @@ -360,7 +313,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.5.0" + "source": "https://github.com/guzzle/psr7/tree/2.6.1" }, "funding": [ { @@ -376,7 +329,7 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:11:26+00:00" + "time": "2023-08-27T10:13:57+00:00" }, { "name": "hosteurope/password-generator", @@ -743,16 +696,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -789,9 +742,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -1117,6 +1070,57 @@ } ], "time": "2022-01-02T09:53:40+00:00" + }, + { + "name": "ulrichsg/getopt-php", + "version": "v4.0.3", + "source": { + "type": "git", + "url": "https://github.com/getopt-php/getopt-php.git", + "reference": "91c31c9bc0ff9bbe22b0b02c63c7f5ddb8d2a8d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/getopt-php/getopt-php/zipball/91c31c9bc0ff9bbe22b0b02c63c7f5ddb8d2a8d5", + "reference": "91c31c9bc0ff9bbe22b0b02c63c7f5ddb8d2a8d5", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "^3.5.8", + "tflori/phpunit-printer": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "GetOpt\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ulrich Schmidt-Goertz", + "email": "ulrich@schmidt-goertz.de" + }, + { + "name": "Thomas Flori", + "email": "thflori@gmail.com" + } + ], + "description": "Command line arguments parser for PHP 7.1 and above", + "homepage": "http://getopt-php.github.io/getopt-php", + "support": { + "issues": "https://github.com/getopt-php/getopt-php/issues", + "source": "https://github.com/getopt-php/getopt-php/tree/v4.0.3" + }, + "time": "2022-12-13T20:37:45+00:00" } ], "packages-dev": [ @@ -1197,5 +1201,5 @@ "platform-overrides": { "php": "7.3.33" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/lib/CLI.php b/lib/CLI.php index ec24362d..6c817178 100644 --- a/lib/CLI.php +++ b/lib/CLI.php @@ -11,40 +11,12 @@ use JKingWeb\Arsse\REST\Fever\User as Fever; use JKingWeb\Arsse\ImportExport\OPML; use JKingWeb\Arsse\REST\Miniflux\Token as Miniflux; use JKingWeb\Arsse\Service\Daemon; +use GetOpt\GetOpt; +use GetOpt\Command; +use GetOpt\Operand; +use GetOpt\Option; class CLI { - public const USAGE = << [] [--admin] - arsse.php user remove - arsse.php user show - arsse.php user set - arsse.php user unset - arsse.php user set-pass [] [--fever] - arsse.php user unset-pass [--fever] - arsse.php user auth [--fever] - arsse.php token list - arsse.php token create [