Skip to content

Commit

Permalink
update some iamges, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 15, 2021
1 parent 3dedff9 commit cda2a91
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Examples:

you can see:

![run-example](_examples/images/run-example.jpg)
![run-example](_examples/images/run-example.png)

#### Display Command Help

Expand Down Expand Up @@ -289,7 +289,7 @@ func exampleExecute(c *gcli.Command, args []string) error {
go build ./_examples/cliapp.go && ./cliapp example -h
```

![cmd-help](_examples/images/cmd-help.jpg)
![cmd-help](_examples/images/cmd-help.png)

### Bind Option(flag)

Expand Down
6 changes: 3 additions & 3 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func main() {
./cliapp help {command}
```

![cmd-help](_examples/images/cmd-help.jpg)
![cmd-help](_examples/images/cmd-help.png)

#### 相似命令提示

Expand All @@ -162,7 +162,7 @@ func main() {

可以观察到选项和参数的搜集结果:

![run-example](_examples/images/run-example.jpg)
![run-example](_examples/images/run-example.png)

## 生成命令补全脚本

Expand Down Expand Up @@ -302,7 +302,7 @@ go build ./_examples/cliapp.go && ./cliapp example -h

> 漂亮的帮助信息就已经自动生成并展示出来了
![cmd-help](_examples/images/cmd-help.jpg)
![cmd-help](_examples/images/cmd-help.png)

### 添加选项

Expand Down
14 changes: 8 additions & 6 deletions _examples/cmd/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,29 @@ var Example = &gcli.Command{
// example run:
// go run ./_examples/cliapp.go ex -c some.txt -d ./dir --id 34 -n tom -n john val0 val1 val2 arrVal0 arrVal1 arrVal2
func exampleExecute(c *gcli.Command, args []string) error {
color.Cyan.Println("hello, in example command")
color.Infoln("hello, in example command")

if exampleOpts.showErr {
return c.Errorf("OO, An error has occurred!!")
}

magentaln := color.Magenta.Println

magentaln("All options:")
fmt.Printf("%+v\n", exampleOpts)
color.Cyanln("All Aptions:")
// fmt.Printf("%+v\n", exampleOpts)
dump.V(exampleOpts)
magentaln("Remain args:")
fmt.Printf("%v\n", args)

color.Cyanln("Remain Args:")
// fmt.Printf("%v\n", args)
dump.P(args)

magentaln("Get arg by name:")
arr := c.Arg("arg0")
fmt.Printf("named arg '%s', value: %#v\n", arr.Name, arr.Value)

magentaln("All named args:")
for _, arg := range c.Args() {
fmt.Printf("named arg '%s': %+v\n", arg.Name, arg.Value)
fmt.Printf("- named arg '%s': %+v\n", arg.Name, arg.Value)
}

return nil
Expand Down
Binary file removed _examples/images/cmd-help.jpg
Binary file not shown.
Binary file removed _examples/images/cmd-list.jpg
Binary file not shown.
Binary file added _examples/images/run-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cda2a91

Please sign in to comment.