Skip to content

Commit f79ef70

Browse files
authored
docs: add usage instructions for running commands in artisan shell script (#83)
* Fix return value errors in `artisan-console.md` * docs: add usage instructions for running commands in `artisan` shell script
1 parent f92bdc1 commit f79ef70

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

digging-deeper/artisan-console.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Then you can simply run your commands like this:
2828
artisan make:controller DemoController
2929
```
3030

31+
You can also use `artisan` shell script like this:
32+
```shell
33+
./artisan make:controller DemoController
34+
```
35+
3136
### Generating Commands
3237

3338
You can use the `make:command` command to create a new command in the `app/console/commands` directory. Don't worry if this directory does not exist in your application, it will be created the first time you run the `make:command` command:
@@ -141,9 +146,9 @@ Notice: When using both arguments and options, define the options before the arg
141146

142147
```shell
143148
// Right
144-
go run . artisan emails --lang Chinese name
149+
go run . artisan emails --lang=Chinese name
145150
// Wrong
146-
go run . artisan emails name --lang Chinese name
151+
go run . artisan emails name --lang=Chinese name
147152
```
148153

149154
Except `command.StringFlag`, we can also use other type `Flag` and `Option*`: `StringSliceFlag`, `BoolFlag`, `Float64Flag`, `Float64SliceFlag`, `IntFlag`, `IntSliceFlag`, `Int64Flag`, `Int64SliceFlag`.

zh/digging-deeper/artisan-console.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ echo -e "\r\nalias artisan=\"go run . artisan\"" >>~/.zshrc
2828
artisan make:controller DemoController
2929
```
3030

31+
你也可以使用 `artisan` shell 脚本来运行:
32+
33+
```shell
34+
./artisan make:controller DemoController
35+
```
36+
3137
### 生成命令
3238

3339
使用 `make:command` 命令将在 `app/console/commands` 目录中创建一个新的命令。如果你的应用程序中不存在此目录,请不要担心,它将在你第一次运行 make:command 命令时自动创建:
@@ -133,17 +139,17 @@ func (receiver *ListCommand) Handle(ctx console.Context) error {
133139
使用:
134140

135141
```shell
136-
go run . artisan emails --lang Chinese
137-
go run . artisan emails -l Chinese
142+
go run . artisan emails --lang=Chinese
143+
go run . artisan emails -l=Chinese
138144
```
139145

140146
注意:同时使用参数与选项时,选项要在参数之前定义,例如:
141147

142148
```shell
143149
// 正确
144-
go run . artisan emails --lang Chinese name
150+
go run . artisan emails --lang=Chinese name
145151
// 错误
146-
go run . artisan emails name --lang Chinese name
152+
go run . artisan emails name --lang=Chinese name
147153
```
148154

149155
除了 `command.StringFlag`,我们还可以其他类型的 `Flag``Option*``StringSliceFlag`, `BoolFlag`, `Float64Flag`, `Float64SliceFlag`, `IntFlag`, `IntSliceFlag`, `Int64Flag`, `Int64SliceFlag`

0 commit comments

Comments
 (0)