Skip to content

Commit

Permalink
Merge pull request #2 from adamreese/fix/default-args
Browse files Browse the repository at this point in the history
fix(cli): allow default action to accept args
  • Loading branch information
technosophos committed Jul 5, 2016
2 parents 1ece13e + f45ab35 commit 5327c27
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions godir.go
Expand Up @@ -37,12 +37,7 @@ func main() {
app.Name = "godir"
app.Usage = Description
app.Version = version
app.Action = func(c *cli.Context) {
sp := putil.Subpaths(wdir(), true)
for _, p := range sp {
fmt.Println(putil.Name(p))
}
}
app.Action = listPackages
commands(app)
app.Run(os.Args)
}
Expand All @@ -66,15 +61,9 @@ func commands(app *cli.App) {
},
},
{
Name: "pkgs",
Usage: "Print all packages (that contain Go code) from the current directory. Skip vendor/",
Action: func(c *cli.Context) {
wd := argOrWdir(c)
sp := putil.Subpaths(wd, true)
for _, p := range sp {
fmt.Println(putil.Name(p))
}
},
Name: "pkgs",
Usage: "Print all packages (that contain Go code) from the current directory. Skip vendor/",
Action: listPackages,
},
{
Name: "paths",
Expand Down Expand Up @@ -103,6 +92,13 @@ func commands(app *cli.App) {
}
}

func listPackages(c *cli.Context) {
sp := putil.Subpaths(argOrWdir(c), true)
for _, p := range sp {
fmt.Println(putil.Name(p))
}
}

func argOrWdir(c *cli.Context) string {
a := c.Args()
if len(a) < 1 {
Expand Down

0 comments on commit 5327c27

Please sign in to comment.