diff --git a/docs/en/command.md b/docs/en/command.md index 3d7391e05..9c8f25ff1 100644 --- a/docs/en/command.md +++ b/docs/en/command.md @@ -179,14 +179,16 @@ The following code only modifies the content in `configure` and `handle`. ### Set Help -``` +```php public function configure() { parent::configure(); $this->setHelp('Hyperf's custom command demonstration'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# output ... Help: Hyperf's custom command demonstration @@ -195,14 +197,16 @@ Help: ### Set Description -``` +```php public function configure() { parent::configure(); $this->setDescription('Hyperf Demo Command'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# output ... Description: Hyperf Demo Command @@ -211,14 +215,16 @@ Description: ### Set Usage -``` +```php public function configure() { parent::configure(); $this->addUsage('--name Demo Code'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# output ... Usage: demo:command @@ -237,7 +243,7 @@ The parameters support the following modes. #### Optional type -``` +```php public function configure() { parent::configure(); @@ -248,8 +254,10 @@ public function handle() { $this->line($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# output ... Hyperf @@ -260,7 +268,7 @@ Swoole #### Array type -``` +```php public function configure() { parent::configure(); @@ -271,8 +279,10 @@ public function handle() { var_dump($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command Hyperf Swoole +# output ... array(2) { [0]=> @@ -295,7 +305,7 @@ The options support the following modes. #### Whether to pass in options -``` +```php public function configure() { parent::configure(); @@ -306,14 +316,18 @@ public function handle() { var_dump($this->input->getOption('opt')); } - +``` +```bash $ php bin/hyperf.php demo:command +# output bool(false) $ php bin/hyperf.php demo:command -o +# output bool(true) $ php bin/hyperf.php demo:command --opt +# output bool(true) ``` @@ -321,7 +335,7 @@ bool(true) `VALUE_OPTIONAL` is no different from `VALUE_REQUIRED` when used alone. -``` +```php public function configure() { parent::configure(); @@ -332,11 +346,14 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# output string(6) "Hyperf" $ php bin/hyperf.php demo:command --name Swoole +# output string(6) "Swoole" ``` @@ -344,7 +361,7 @@ string(6) "Swoole" `VALUE_IS_ARRAY` and `VALUE_OPTIONAL`, when used together, can achieve the effect of passing multiple `Option`s. -``` +```php public function configure() { parent::configure(); @@ -355,12 +372,15 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# output array(0) { } $ php bin/hyperf.php demo:command --name Hyperf --name Swoole +# output array(2) { [0]=> string(6) "Hyperf" diff --git a/docs/zh-cn/command.md b/docs/zh-cn/command.md index e76db5a03..6ad0b581e 100644 --- a/docs/zh-cn/command.md +++ b/docs/zh-cn/command.md @@ -173,30 +173,35 @@ class FooCommand extends HyperfCommand ### 设置 Help -``` +```php public function configure() { parent::configure(); $this->setHelp('Hyperf 自定义命令演示'); } +``` +```bash $ php bin/hyperf.php demo:command --help +# 输出 ... Help: Hyperf 自定义命令演示 - ``` + ### 设置 Description -``` +```php public function configure() { parent::configure(); $this->setDescription('Hyperf Demo Command'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 输出 ... Description: Hyperf Demo Command @@ -205,14 +210,16 @@ Description: ### 设置 Usage -``` +```php public function configure() { parent::configure(); $this->addUsage('--name 演示代码'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 输出 ... Usage: demo:command @@ -231,7 +238,7 @@ Usage: #### 可选类型 -``` +```php public function configure() { parent::configure(); @@ -242,19 +249,22 @@ public function handle() { $this->line($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 输出 ... Hyperf $ php bin/hyperf.php demo:command Swoole +# 输出 ... Swoole ``` #### 数组类型 -``` +```php public function configure() { parent::configure(); @@ -265,8 +275,10 @@ public function handle() { var_dump($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command Hyperf Swoole +# 输出 ... array(2) { [0]=> @@ -289,7 +301,7 @@ array(2) { #### 是否传入可选项 -``` +```php public function configure() { parent::configure(); @@ -300,14 +312,18 @@ public function handle() { var_dump($this->input->getOption('opt')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 输出 bool(false) $ php bin/hyperf.php demo:command -o +# 输出 bool(true) $ php bin/hyperf.php demo:command --opt +# 输出 bool(true) ``` @@ -315,7 +331,7 @@ bool(true) `VALUE_OPTIONAL` 在单独使用上与 `VALUE_REQUIRED` 并无二致 -``` +```php public function configure() { parent::configure(); @@ -326,11 +342,14 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 输出 string(6) "Hyperf" $ php bin/hyperf.php demo:command --name Swoole +# 输出 string(6) "Swoole" ``` @@ -338,7 +357,7 @@ string(6) "Swoole" `VALUE_IS_ARRAY` 和 `VALUE_OPTIONAL` 配合使用,可以达到传入多个 `Option` 的效果。 -``` +```php public function configure() { parent::configure(); @@ -349,12 +368,15 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 输出 array(0) { } $ php bin/hyperf.php demo:command --name Hyperf --name Swoole +# 输出 array(2) { [0]=> string(6) "Hyperf" diff --git a/docs/zh-hk/command.md b/docs/zh-hk/command.md index b74d83983..1764532c2 100644 --- a/docs/zh-hk/command.md +++ b/docs/zh-hk/command.md @@ -173,14 +173,16 @@ class FooCommand extends HyperfCommand ### 設置 Help -``` +```php public function configure() { parent::configure(); $this->setHelp('Hyperf 自定義命令演示'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 輸出 ... Help: Hyperf 自定義命令演示 @@ -189,14 +191,16 @@ Help: ### 設置 Description -``` +```php public function configure() { parent::configure(); $this->setDescription('Hyperf Demo Command'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 輸出 ... Description: Hyperf Demo Command @@ -205,14 +209,16 @@ Description: ### 設置 Usage -``` +```php public function configure() { parent::configure(); $this->addUsage('--name 演示代碼'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 輸出 ... Usage: demo:command @@ -231,7 +237,7 @@ Usage: #### 可選類型 -``` +```php public function configure() { parent::configure(); @@ -242,19 +248,22 @@ public function handle() { $this->line($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 ... Hyperf $ php bin/hyperf.php demo:command Swoole +# 輸出 ... Swoole ``` #### 數組類型 -``` +```php public function configure() { parent::configure(); @@ -265,8 +274,10 @@ public function handle() { var_dump($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command Hyperf Swoole +# 輸出 ... array(2) { [0]=> @@ -289,7 +300,7 @@ array(2) { #### 是否傳入可選項 -``` +```php public function configure() { parent::configure(); @@ -300,14 +311,18 @@ public function handle() { var_dump($this->input->getOption('opt')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 bool(false) $ php bin/hyperf.php demo:command -o +# 輸出 bool(true) $ php bin/hyperf.php demo:command --opt +# 輸出 bool(true) ``` @@ -315,7 +330,7 @@ bool(true) `VALUE_OPTIONAL` 在單獨使用上與 `VALUE_REQUIRED` 並無二致 -``` +```php public function configure() { parent::configure(); @@ -326,11 +341,14 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 string(6) "Hyperf" $ php bin/hyperf.php demo:command --name Swoole +# 輸出 string(6) "Swoole" ``` @@ -338,7 +356,7 @@ string(6) "Swoole" `VALUE_IS_ARRAY` 和 `VALUE_OPTIONAL` 配合使用,可以達到傳入多個 `Option` 的效果。 -``` +```php public function configure() { parent::configure(); @@ -349,12 +367,15 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 array(0) { } $ php bin/hyperf.php demo:command --name Hyperf --name Swoole +# 輸出 array(2) { [0]=> string(6) "Hyperf" diff --git a/docs/zh-tw/command.md b/docs/zh-tw/command.md index c61c7e4b8..aa12a99c9 100644 --- a/docs/zh-tw/command.md +++ b/docs/zh-tw/command.md @@ -173,14 +173,16 @@ class FooCommand extends HyperfCommand ### 設定 Help -``` +```php public function configure() { parent::configure(); $this->setHelp('Hyperf 自定義命令演示'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 輸出 ... Help: Hyperf 自定義命令演示 @@ -189,14 +191,16 @@ Help: ### 設定 Description -``` +```php public function configure() { parent::configure(); $this->setDescription('Hyperf Demo Command'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 輸出 ... Description: Hyperf Demo Command @@ -205,14 +209,16 @@ Description: ### 設定 Usage -``` +```php public function configure() { parent::configure(); $this->addUsage('--name 演示程式碼'); } - +``` +```bash $ php bin/hyperf.php demo:command --help +# 輸出 ... Usage: demo:command @@ -231,7 +237,7 @@ Usage: #### 可選型別 -``` +```php public function configure() { parent::configure(); @@ -242,19 +248,22 @@ public function handle() { $this->line($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 ... Hyperf $ php bin/hyperf.php demo:command Swoole +# 輸出 ... Swoole ``` #### 陣列型別 -``` +```php public function configure() { parent::configure(); @@ -265,8 +274,10 @@ public function handle() { var_dump($this->input->getArgument('name')); } - +``` +```bash $ php bin/hyperf.php demo:command Hyperf Swoole +# 輸出 ... array(2) { [0]=> @@ -289,7 +300,7 @@ array(2) { #### 是否傳入可選項 -``` +```php public function configure() { parent::configure(); @@ -300,14 +311,18 @@ public function handle() { var_dump($this->input->getOption('opt')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 bool(false) $ php bin/hyperf.php demo:command -o +# 輸出 bool(true) $ php bin/hyperf.php demo:command --opt +# 輸出 bool(true) ``` @@ -315,7 +330,7 @@ bool(true) `VALUE_OPTIONAL` 在單獨使用上與 `VALUE_REQUIRED` 並無二致 -``` +```php public function configure() { parent::configure(); @@ -326,11 +341,14 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 string(6) "Hyperf" $ php bin/hyperf.php demo:command --name Swoole +# 輸出 string(6) "Swoole" ``` @@ -338,7 +356,7 @@ string(6) "Swoole" `VALUE_IS_ARRAY` 和 `VALUE_OPTIONAL` 配合使用,可以達到傳入多個 `Option` 的效果。 -``` +```php public function configure() { parent::configure(); @@ -349,12 +367,15 @@ public function handle() { var_dump($this->input->getOption('name')); } - +``` +```bash $ php bin/hyperf.php demo:command +# 輸出 array(0) { } $ php bin/hyperf.php demo:command --name Hyperf --name Swoole +# 輸出 array(2) { [0]=> string(6) "Hyperf"