diff --git a/app/Console/Command/ToolCommand.php b/app/Console/Command/ToolCommand.php new file mode 100644 index 0000000..2cb83b8 --- /dev/null +++ b/app/Console/Command/ToolCommand.php @@ -0,0 +1,40 @@ +showHelp(); + } +} diff --git a/app/Console/SubCmd/OpenCmd.php b/app/Console/SubCmd/OpenCmd.php new file mode 100644 index 0000000..e6dc150 --- /dev/null +++ b/app/Console/SubCmd/OpenCmd.php @@ -0,0 +1,41 @@ +flags->addOptByRule($name, $rule); + } + + /** + * Do execute command + * + * @param Input $input + * @param Output $output + * + * @return int|mixed + */ + protected function execute(Input $input, Output $output): mixed + { + return $this->showHelp(); + } +} diff --git a/app/Console/SubCmd/OpenUrlCmd.php b/app/Console/SubCmd/OpenUrlCmd.php new file mode 100644 index 0000000..0a0d0f5 --- /dev/null +++ b/app/Console/SubCmd/OpenUrlCmd.php @@ -0,0 +1,43 @@ +flags->addOptByRule($name, $rule); + $this->flags->addArg('url', 'want opened URL address', 'string', true); + } + + /** + * @param Input $input + * @param Output $output + * + * @return int|mixed + */ + protected function execute(Input $input, Output $output): mixed + { + $pageUrl = $this->flags->getArg('url'); + if (!str_starts_with($pageUrl, 'http')) { + $pageUrl = 'https://' . $pageUrl; + } + + $output->info("will open URL: $pageUrl"); + AppHelper::openBrowser($pageUrl); + + return 0; + } +} diff --git a/config/aliases.php b/config/aliases.php index ffcbdcb..f457a7c 100644 --- a/config/aliases.php +++ b/config/aliases.php @@ -4,9 +4,10 @@ // element is: alias command => real command return [ 'ac' => 'git:ac', - 'acp' => 'git:acp', + 'acp' => 'git acp', 'glpr' => 'gitlab:pr', 'config' => 'self config', 'webui' => 'self webui', 'add-log' => 'util log', + 'open-url' => 'tool open url', ];