Skip to content

Commit dc39b9d

Browse files
Tidy up a few bits
1 parent 8abcd71 commit dc39b9d

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

command.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,6 @@ func (cmd *Command) ExtraArgs() (args []string, ok bool) {
316316

317317
// Flags returns the set of flags for the command.
318318
func (cmd *Command) flagSet() *flag.Set {
319-
if cmd == nil {
320-
// Only thing to do really, slightly more helpful than a generic
321-
// nil pointer dereference
322-
panic("flagSet called on a nil Command")
323-
}
324-
325319
if cmd.flags == nil {
326320
return flag.NewSet()
327321
}

option.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func (c *config) build() *Command {
9292
// Successive calls will simply overwrite any previous calls. Without this option
9393
// the command will default to [os.Stdin].
9494
//
95+
// Subcommands cannot override the stdin of the root command, when retrieving the
96+
// stdin with [Command.Stdin], the root's stdin will be returned.
97+
//
9598
// // Set stdin to os.Stdin (the default anyway)
9699
// cli.New("test", cli.Stdin(os.Stdin))
97100
func Stdin(stdin io.Reader) Option {
@@ -113,6 +116,9 @@ func Stdin(stdin io.Reader) Option {
113116
// Successive calls will simply overwrite any previous calls. Without this option
114117
// the command will default to [os.Stdout].
115118
//
119+
// Subcommands cannot override the stdout of the root command, when retrieving the
120+
// stdout with [Command.Stdout], the root's stdout will be returned.
121+
//
116122
// // Set stdout to a temporary buffer
117123
// buf := &bytes.Buffer{}
118124
// cli.New("test", cli.Stdout(buf))
@@ -135,6 +141,9 @@ func Stdout(stdout io.Writer) Option {
135141
// Successive calls will simply overwrite any previous calls. Without this option
136142
// the command will default to [os.Stderr].
137143
//
144+
// Subcommands cannot override the stderr of the root command, when retrieving the
145+
// stdin with [Command.Stderr], the root's stderr will be returned.
146+
//
138147
// // Set stderr to a temporary buffer
139148
// buf := &bytes.Buffer{}
140149
// cli.New("test", cli.Stderr(buf))

0 commit comments

Comments
 (0)