breakup v2 documentation
This commit is contained in:
29
docs/v2/examples/arguments.md
Normal file
29
docs/v2/examples/arguments.md
Normal file
@@ -0,0 +1,29 @@
|
||||
You can lookup arguments by calling the `Args` function on `cli.Context`, e.g.:
|
||||
|
||||
<!-- {
|
||||
"output": "Hello \""
|
||||
} -->
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := &cli.App{
|
||||
Action: func(cCtx *cli.Context) error {
|
||||
fmt.Printf("Hello %q", cCtx.Args().Get(0))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user