Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/urfave/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhur1997 committed Jan 28, 2021
2 parents fc1d3eb + 44ec985 commit e73d6e1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
33 changes: 33 additions & 0 deletions app_test.go
Expand Up @@ -897,6 +897,39 @@ func TestApp_SetStdin(t *testing.T) {
}
}

func TestApp_SetStdin_Subcommand(t *testing.T) {
buf := make([]byte, 12)

app := &App{
Name: "test",
Reader: strings.NewReader("Hello World!"),
Commands: []*Command{
{
Name: "command",
Subcommands: []*Command{
{
Name: "subcommand",
Action: func(c *Context) error {
_, err := c.App.Reader.Read(buf)
return err
},
},
},
},
},
}

err := app.Run([]string{"test", "command", "subcommand"})

if err != nil {
t.Fatalf("Run error: %s", err)
}

if string(buf) != "Hello World!" {
t.Error("App did not read input from desired reader.")
}
}

func TestApp_SetStdout(t *testing.T) {
var w bytes.Buffer

Expand Down
1 change: 1 addition & 0 deletions command.go
Expand Up @@ -243,6 +243,7 @@ func (c *Command) startApp(ctx *Context) error {
app.Version = ctx.App.Version
app.HideVersion = true
app.Compiled = ctx.App.Compiled
app.Reader = ctx.App.Reader
app.Writer = ctx.App.Writer
app.ErrWriter = ctx.App.ErrWriter
app.ExitErrHandler = ctx.App.ExitErrHandler
Expand Down
2 changes: 1 addition & 1 deletion docs/v1/manual.md
Expand Up @@ -612,7 +612,7 @@ given sources.
Here is a more complete sample of a command using YAML support:

<!-- {
"args": ["test-cmd", "&#45;&#45;help"],
"args": ["&#45;&#45;help"],
"output": "&#45&#45;test value.*default: 0"
} -->
``` go
Expand Down
2 changes: 1 addition & 1 deletion docs/v2/manual.md
Expand Up @@ -627,7 +627,7 @@ given sources.
Here is a more complete sample of a command using YAML support:

<!-- {
"args": ["test-cmd", "&#45;&#45;help"],
"args": ["&#45;&#45;help"],
"output": "&#45&#45;test value.*default: 0"
} -->
``` go
Expand Down

0 comments on commit e73d6e1

Please sign in to comment.