summaryrefslogtreecommitdiff
path: root/argv.go
blob: a203c8e482a163e5192152c8207cbee1193c5725 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main

/*
	this parses the command line arguements
	this enables command line options from other packages like 'gui' and 'log'
*/

import (
	"fmt"
	"os"

	"go.wit.com/dev/alexflint/arg"
)

var argv args

type args struct {
	Pull     *EmptyCmd `arg:"subcommand:pull"          help:"'git pull' on the repos"`
	List     *EmptyCmd `arg:"subcommand:list"          help:"list the repos"`
	Gui      *EmptyCmd `arg:"subcommand:gui"           help:"show gui"`
	Merge    *EmptyCmd `arg:"subcommand:merge"         help:"merge in new patchsets"`
	Init     *EmptyCmd `arg:"subcommand:init"          help:"init the repo list"`
	Port     int       `arg:"--port" default:"2520" help:"port to run on"`
	Hostname string    `arg:"--hostname" default:"forge.wit.com" help:"hostname to use"`
	Daemon   bool      `arg:"--daemon"                             help:"run as a daemon"`
	Force    bool      `arg:"--force"                              help:"try to strong arm things"`
	Verbose  bool      `arg:"--verbose"                            help:"show more output"`
}

type EmptyCmd struct {
}

func (args) Version() string {
	return ARGNAME + " " + VERSION + "    Built on " + BUILDTIME
}

func init() {
	arg.MustParse(&argv)
}

func (a args) DoAutoComplete(argv []string) {
	// argv.doBashHelp()
	switch argv[0] {
	case "merge":
		fmt.Println("--force")
	default:
		if argv[0] == ARGNAME {
			// list the subcommands here
			fmt.Println("list merge")
		}
	}
	os.Exit(0)
}