Skip to content

Commit

Permalink
Update GUIDE.md (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Mar 3, 2022
1 parent e47f3e0 commit 563adc4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions GUIDE.md
@@ -1,5 +1,25 @@
# Guide for acmd

## Default command

Sometimes the app should work without any commands (ex `./app`), `acmd` doesn't have a feature for that, if command is not passed `help` will be used.

But if you really want to have default command for the app you can do:

```go
func main() {
cmds := []acmd.Command{...}

if len(os.Args) <= 1 { // no command is passed?
os.Args = []string{"", cmds[0].Name} // change the app args
}

// just create acmd.Runner as usual
}
```

Note: this solution doesn't work with flags, consider to create a command even if you have just 1.

## Flag

Example with command like that `./dummy server ./openapi.yml -port=8080` from [dummy](https://github.com/neotoolkit/dummy/blob/main/cmd/dummy/main.go)
Expand Down

0 comments on commit 563adc4

Please sign in to comment.