1package main
2
3import (
4	"fmt"
5	"os"
6
7	"gopkg.in/alecthomas/kingpin.v2"
8)
9
10// Context for "ls" command
11type LsCommand struct {
12	All bool
13}
14
15func (l *LsCommand) run(c *kingpin.ParseContext) error {
16	fmt.Printf("all=%v\n", l.All)
17	return nil
18}
19
20func configureLsCommand(app *kingpin.Application) {
21	c := &LsCommand{}
22	ls := app.Command("ls", "List files.").Action(c.run)
23	ls.Flag("all", "List all files.").Short('a').BoolVar(&c.All)
24}
25
26func main() {
27	app := kingpin.New("modular", "My modular application.")
28	configureLsCommand(app)
29	kingpin.MustParse(app.Parse(os.Args[1:]))
30}
31