summaryrefslogtreecommitdiff
path: root/argv.go
blob: a32f87dcb758918440c971c6ed1d22ac03fa1741 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main

/*
	this parses the command line arguements
*/

var argv args

type FindCmd struct {
	All       bool `arg:"--all"                           help:"select every repo"`
	ReadOnly  bool `arg:"--readonly"                      help:"include read-only repos"`
	Mine      bool `arg:"--mine"                          help:"your repos as defined in the forge config"`
	Favorites bool `arg:"--favorites"                     help:"your repos configured as favorites"`
	Private   bool `arg:"--private"                       help:"private repos from your .config/forge/"`
}

type DoCmd struct {
	List      bool `arg:"--list"                            help:"just show a table of the current state"`
	Clone     bool `arg:"--clone"                           help:"git clone build dependancies"`
	Scan      bool `arg:"--scan"                            help:"reload protobuf from .git/"`
	Force     bool `arg:"--force"                           help:"force redo things"`
	GitPull   bool `arg:"--git-pull"                        help:"run 'git pull'"`
	GitReset  bool `arg:"--git-reset"                       help:"run 'git reset --hard'"`
	Build     bool `arg:"--build"      default:"true"       help:"try to build it"`
	Install   bool `arg:"--install"                         help:"also try to install it"`
	RedoGoMod bool `arg:"--RedoGoMod"                       help:"remake all the go.sum and go.mod files"`
}

/*
arg.MustParse(&args)

switch {
case args.Checkout != nil:
	fmt.Printf("checkout requested for branch %s\n", args.Checkout.Branch)
case args.Commit != nil:
	fmt.Printf("commit requested with message \"%s\"\n", args.Commit.Message)
case args.Push != nil:
	fmt.Printf("push requested from %s to %s\n", args.Push.Branch, args.Push.Remote)
}
*/

type args struct {
	Find         *FindCmd `arg:"subcommand:find"                      help:"select repos (for example, --all or --mine)"`
	Do           *DoCmd   `arg:"subcommand:do"                        help:"do something ('git pull', 'build', 'install', etc)"`
	Config       bool     `arg:"--config"                             help:"show your .config/forge/ settings"`
	DoPatchSet   bool     `arg:"--make-patchset"                      help:"make patch set"`
	ListPatchSet bool     `arg:"--list-patchset"                      help:"list patch sets"`
	DryRun       bool     `arg:"--dry-run"                            help:"show what would be run"`
	Fix          bool     `arg:"--fix"                                help:"fix config, save config & exit"`
	Delete       string   `arg:"--delete"                             help:"delete this repo"`
	Dirty        bool     `arg:"--dirty"                              help:"git CheckDirty() on every repo"`
	User         bool     `arg:"--user"                               help:"git checkout user"`
	Devel        bool     `arg:"--devel"                              help:"git checkout devel"`
	Master       bool     `arg:"--master"                             help:"git checkout master"`
	URL          string   `arg:"--connect"                            help:"gowebd url"`
	Register     string   `arg:"--register"                           help:"register your git URL (foo.com/mystuff) or (github.com/foo/bar)"`
}

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

func (a args) Description() string {
	return `
forge -- in the spirit of things like sourceforge

Examples:
	forge --config                               # shows your forge config (~/.config/forge/)
	forge find --all   do --pull                 # run 'git pull' in every repo
	forge find --mine  do --clone                # git clone every package you have in your config file
	forge find --all   do --build --dry-run      # build every binary package (but just show what would run)
	forge find --all   --user                    # checkout the user branch
	forge find --all   --devel                   # checkout the devel branch
	forge find --all   --master                  # checkout the master branch

	# these options are intended for automation. You probably just want to use the GUI.
	`
}

// forge  --map lib/foo    https://github.com/me/myfoo  # map go.wit.com/lib/foo -> github.com/me/myfoo