File: cmd_cmd2.go

package info (click to toggle)
golang-github-smira-commander 0.0~git20140515.f408b00-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 116 kB
  • sloc: makefile: 3
file content (34 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"fmt"

	"github.com/gonuts/commander"
	"github.com/gonuts/flag"
)

func ex_make_cmd_cmd2() *commander.Command {
	cmd := &commander.Command{
		Run:       ex_run_cmd_cmd2,
		UsageLine: "cmd2 [options]",
		Short:     "runs cmd2 and exits",
		Long: `
runs cmd2 and exits.

ex:
 $ my-cmd cmd2
`,
		Flag: *flag.NewFlagSet("my-cmd-cmd2", flag.ExitOnError),
	}
	cmd.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
	return cmd
}

func ex_run_cmd_cmd2(cmd *commander.Command, args []string) error {
	name := "my-cmd-" + cmd.Name()
	quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
	fmt.Printf("%s: hello from cmd2 (quiet=%v)\n", name, quiet)
	return nil
}

// EOF