mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[fix] BCommand
This commit is contained in:
parent
d6b595db7d
commit
11bc8ca9c8
@ -20,8 +20,7 @@
|
|||||||
"sven/file-config": "^3.1",
|
"sven/file-config": "^3.1",
|
||||||
"hassankhan/config": "^2.2",
|
"hassankhan/config": "^2.2",
|
||||||
"lkeme/inifile": "^3.4",
|
"lkeme/inifile": "^3.4",
|
||||||
"adhocore/cli": "^0.9.0",
|
"adhocore/cli": "^0.9.0"
|
||||||
"vanilla/garden-cli": "^3.1"
|
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
63
composer.lock
generated
63
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "0678ecd04eed6db66de4668ffffec283",
|
"content-hash": "ec8eee201c31224952f597aab5be4ea8",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adhocore/cli",
|
"name": "adhocore/cli",
|
||||||
@ -1790,67 +1790,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-05-27T09:17:38+00:00"
|
"time": "2021-05-27T09:17:38+00:00"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "vanilla/garden-cli",
|
|
||||||
"version": "v3.1.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/vanilla/garden-cli.git",
|
|
||||||
"reference": "d9844c47f4f2812259ee1b583aa66e7b6b5d85c5"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/vanilla/garden-cli/zipball/d9844c47f4f2812259ee1b583aa66e7b6b5d85c5",
|
|
||||||
"reference": "d9844c47f4f2812259ee1b583aa66e7b6b5d85c5",
|
|
||||||
"shasum": "",
|
|
||||||
"mirrors": [
|
|
||||||
{
|
|
||||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
|
||||||
"preferred": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-json": "*",
|
|
||||||
"php": ">=7.2",
|
|
||||||
"psr/log": "^1.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"ergebnis/composer-normalize": "^2.8",
|
|
||||||
"phpdocumentor/reflection-docblock": "^4.3",
|
|
||||||
"phpunit/phpunit": "^8",
|
|
||||||
"vanilla/garden-container": "^3.0",
|
|
||||||
"vanilla/standards": "^1.3",
|
|
||||||
"vimeo/psalm": "^3.16"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-pdo": "Required for the DbUtils class.",
|
|
||||||
"phpdocumentor/reflection-docblock": "Required for the CliApplication functionality.",
|
|
||||||
"vanilla/garden-container": "Required for the CliApplication functionality."
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Garden\\Cli\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Todd Burry",
|
|
||||||
"email": "todd@vanillaforums.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A full-featured, yet ridiculously simple commandline parser for your next php cli script. Stop fighting with getopt().",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/vanilla/garden-cli/issues",
|
|
||||||
"source": "https://github.com/vanilla/garden-cli/tree/v3.1.2"
|
|
||||||
},
|
|
||||||
"time": "2020-10-25T13:36:44+00:00"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
|
|||||||
@ -47,10 +47,9 @@ class App
|
|||||||
*/
|
*/
|
||||||
public function load($argv): App
|
public function load($argv): App
|
||||||
{
|
{
|
||||||
$args = (new Command($argv))->run();
|
$args = (new BCommand($argv))->run();
|
||||||
$filename = $args->getArg(0) ?? 'user.ini';
|
$filename = $args->args()[0] ?? 'user.ini';
|
||||||
$this->script_mode = $args->getOpt('script');
|
$this->script_mode = $args->script;
|
||||||
|
|
||||||
Config::load($filename);
|
Config::load($filename);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,10 +10,9 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Core;
|
namespace BiliHelper\Core;
|
||||||
|
|
||||||
use Garden\Cli\Cli;
|
use Ahc\Cli\Input\Command;
|
||||||
use Garden\Cli\Args;
|
|
||||||
|
|
||||||
class Command
|
class BCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private $argv;
|
private $argv;
|
||||||
@ -27,18 +26,13 @@ class Command
|
|||||||
$this->argv = $argv;
|
$this->argv = $argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function run()
|
||||||
* @return \Garden\Cli\Args
|
|
||||||
*/
|
|
||||||
public function run(): Args
|
|
||||||
{
|
{
|
||||||
$cli = new Cli();
|
$cli = new Command('BHP-S', 'BHP命令行工具.');
|
||||||
|
$cli->version('0.0.1-dev')
|
||||||
$cli->description('BHP命令行工具.')
|
->option('-s --script', '执行的Script模式.',null,false);
|
||||||
->opt('script:s', '执行的Script模式.', false, 'bool');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$args = $cli->parse($this->argv, true);
|
$args = $cli->parse($this->argv);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
die('解析命令行参数错误');
|
die('解析命令行参数错误');
|
||||||
}
|
}
|
||||||
@ -46,7 +40,3 @@ class Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user