Conver to regular Go vendor + dep tool

This commit is contained in:
Andrey Smirnov
2017-03-22 17:38:32 +03:00
parent 070347295e
commit c6c1012330
3260 changed files with 1742550 additions and 72 deletions
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
var cmd_cmd1 = &commander.Command{
Run: ex_run_cmd_cmd1,
UsageLine: "cmd1 [options]",
Short: "runs cmd1 and exits",
Long: `
runs cmd1 and exits.
ex:
$ my-cmd cmd1
`,
Flag: *flag.NewFlagSet("my-cmd-cmd1", flag.ExitOnError),
}
func init() {
cmd_cmd1.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
}
func ex_run_cmd_cmd1(cmd *commander.Command, args []string) error {
name := "my-cmd-" + cmd.Name()
quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
fmt.Printf("%s: hello from cmd1 (quiet=%v)\n", name, quiet)
return nil
}
// EOF
+34
View File
@@ -0,0 +1,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
+18
View File
@@ -0,0 +1,18 @@
package main
import (
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
var cmd_subcmd1 = &commander.Command{
UsageLine: "subcmd1 <command>",
Short: "subcmd1 subcommand. does subcmd1 thingies",
Subcommands: []*commander.Command{
cmd_subcmd1_cmd1,
cmd_subcmd1_cmd2,
},
Flag: *flag.NewFlagSet("my-cmd-subcmd1", flag.ExitOnError),
}
// EOF
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
var cmd_subcmd1_cmd1 = &commander.Command{
Run: ex_run_cmd_subcmd1_cmd1,
UsageLine: "cmd1 [options]",
Short: "runs cmd1 and exits",
Long: `
runs cmd1 and exits.
ex:
$ my-cmd subcmd1 cmd1
`,
Flag: *flag.NewFlagSet("my-cmd-subcmd1-cmd1", flag.ExitOnError),
}
func init() {
cmd_subcmd1_cmd1.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
}
func ex_run_cmd_subcmd1_cmd1(cmd *commander.Command, args []string) error {
name := "my-cmd-subcmd1-" + cmd.Name()
quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
fmt.Printf("%s: hello from subcmd1-cmd1 (quiet=%v)\n", name, quiet)
return nil
}
// EOF
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
var cmd_subcmd1_cmd2 = &commander.Command{
Run: ex_run_cmd_subcmd1_cmd2,
UsageLine: "cmd2 [options]",
Short: "runs cmd2 and exits",
Long: `
runs cmd2 and exits.
ex:
$ my-cmd subcmd1 cmd2
`,
Flag: *flag.NewFlagSet("my-cmd-subcmd1-cmd2", flag.ExitOnError),
}
func init() {
cmd_subcmd1_cmd2.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
}
func ex_run_cmd_subcmd1_cmd2(cmd *commander.Command, args []string) error {
name := "my-cmd-subcmd1-" + cmd.Name()
quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
fmt.Printf("%s: hello from subcmd1-cmd2 (quiet=%v)\n", name, quiet)
return nil
}
// EOF
+22
View File
@@ -0,0 +1,22 @@
package main
import (
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
func ex_make_cmd_subcmd2() *commander.Command {
cmd := &commander.Command{
UsageLine: "subcmd2",
Short: "subcmd2 subcommand. does subcmd2 thingies (help list)",
List: commander.HelpTopicsList,
Subcommands: []*commander.Command{
ex_make_cmd_subcmd2_cmd1(),
ex_make_cmd_subcmd2_cmd2(),
},
Flag: *flag.NewFlagSet("my-cmd-subcmd2", flag.ExitOnError),
}
return cmd
}
// EOF
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
func ex_make_cmd_subcmd2_cmd1() *commander.Command {
cmd := &commander.Command{
Run: ex_run_cmd_subcmd2_cmd1,
UsageLine: "cmd1 [options]",
Short: "runs cmd1 and exits",
Long: `
runs cmd1 and exits.
ex:
$ my-cmd subcmd2 cmd1
`,
Flag: *flag.NewFlagSet("my-cmd-subcmd2-cmd1", 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_subcmd2_cmd1(cmd *commander.Command, args []string) error {
name := "my-cmd-subcmd2-" + cmd.Name()
quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
fmt.Printf("%s: hello from subcmd2-cmd1 (quiet=%v)\n", name, quiet)
return nil
}
// EOF
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
)
func ex_make_cmd_subcmd2_cmd2() *commander.Command {
cmd := &commander.Command{
Run: ex_run_cmd_subcmd2_cmd2,
UsageLine: "cmd2 [options]",
Short: "runs cmd2 and exits",
Long: `
runs cmd2 and exits.
ex:
$ my-cmd subcmd2 cmd2
`,
Flag: *flag.NewFlagSet("my-cmd-subcmd2-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_subcmd2_cmd2(cmd *commander.Command, args []string) error {
name := "my-cmd-subcmd2-" + cmd.Name()
quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
fmt.Printf("%s: hello from subcmd2-cmd2 (quiet=%v)\n", name, quiet)
return nil
}
// EOF
+33
View File
@@ -0,0 +1,33 @@
package main
import (
"fmt"
"os"
"github.com/gonuts/commander"
)
var g_cmd = &commander.Command{
UsageLine: os.Args[0] + " does cool things",
}
func init() {
g_cmd.Subcommands = []*commander.Command{
cmd_cmd1,
ex_make_cmd_cmd2(),
cmd_subcmd1,
ex_make_cmd_subcmd2(),
}
}
func main() {
err := g_cmd.Dispatch(os.Args[1:])
if err != nil {
fmt.Printf("%v\n", err)
os.Exit(1)
}
return
}
// EOF