Skip to content

Commit c062837

Browse files
committed
docs: comment and example for InputInfo.Help
1 parent 588ef00 commit c062837

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ func (in InputInfo) Long(name string) InputInfo {
274274
return in
275275
}
276276

277+
// Help sets the brief help blurb for this option or positional argument.
277278
func (in InputInfo) Help(blurb string) InputInfo {
278279
in.HelpBlurb = blurb
279280
return in

examples_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ func ExampleInputInfo_ShortOnly() {
4040
// unknown option '--flag'
4141
}
4242

43+
func ExampleInputInfo_Help() {
44+
in := cli.New("example").
45+
Help("example program").
46+
Opt(cli.NewOpt("aa").Help("a short one or two sentence blurb"))
47+
48+
_, err := in.ParseThese("-h")
49+
fmt.Println(err)
50+
// Output:
51+
// example - example program
52+
//
53+
// usage:
54+
// example [options]
55+
//
56+
// options:
57+
// --aa <arg> a short one or two sentence blurb
58+
// -h, --help Show this help message and exit.
59+
}
60+
4361
func ExampleInputInfo_WithValueName_option() {
4462
in := cli.New("example").
4563
Help("example program").

0 commit comments

Comments
 (0)