How can I see the flag's base type? #2042
Unanswered
jokemanfire
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Easy. Try this: https://go.dev/play/p/YGGpVX0_4L4 View Sourcepackage main
import (
"context"
"fmt"
"net/mail"
"os"
"time"
cli "github.com/urfave/cli/v3"
)
func main() {
cmd := &cli.Command{
Name: "greet",
Version: "0.1.0",
Description: "This is how we describe greet the app",
Authors: []any{
&mail.Address{Name: "Harrison", Address: "[email protected]"},
"Oliver Allen <[email protected]>",
},
Flags: []cli.Flag{
&cli.StringFlag{Name: "name", Value: "bob", Usage: "a name (`string`) to say"},
},
Arguments: cli.AnyArguments,
Commands: []*cli.Command{
{
Name: "describeit",
Aliases: []string{"d"},
Usage: "use it to see a description",
Description: "This is how we describe describeit the function",
ArgsUsage: "[arguments...]",
Action: func(context.Context, *cli.Command) error {
fmt.Printf("i like to describe things")
return nil
},
},
},
}
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
// Simulate the command line arguments
os.Args = []string{"greet", "help"}
_ = cmd.Run(ctx, os.Args)
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
I have search the document , and i find that https://cli.urfave.org/v2/examples/flags/#placeholder-values . |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Such like:
GLOBAL OPTIONS:
--lang value, -l value language for the greeting (default: "english")
--help, -h show help
I want
--lang string, -l string language for the greeting (default: "english")
--help, -h show help
I want the flag type to be show. not "value".
Beta Was this translation helpful? Give feedback.
All reactions