summaryrefslogtreecommitdiff
path: root/argv.go
blob: 3b8637c2e7b906643b1e2b6d30441c9f7c220b19 (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
package main

import (
	"os"

	"go.wit.com/lib/protobuf/argvpb"
)

/*
	this parses the command line arguements

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

// argv    *argvpb.Argv   // more experiments for bash handling
// me.argv = argvpb.Autocomplete(&argv) // adds shell auto complete to go-args

var argv args

type args struct {
	Repo         string `arg:"positional"                     help:"go import path"`
	AutoWork     bool   `arg:"--work"       default:"false"   help:"recreate the go.work file"`
	DryRun       bool   `arg:"--dry-run"                      help:"show what would be run"`
	NonRecursive bool   `arg:"--non-recursive"        help:"recursively clone all dependencies"`
	Build        bool   `arg:"--build"                        help:"try to build it after clone"`
	Install      bool   `arg:"--install"                      help:"try to install it after clone"`
	Ignore       bool   `arg:"--ignore"     default:"false"   help:"ignore weird clone errors from non-standard repos"`
	// Fetch     bool   `arg:"--git-fetch"      default:"false" help:"run 'git fetch' on all your repos"`
}

func (args) Version() string {
	return "go-clone " + VERSION + "    Built on " + BUILDTIME
}

func (args) Buildtime() (string, string) {
	return BUILDTIME, VERSION
}

func (a args) Description() string {
	return `
git clone go repositories recursively

Examples:
	go-clone go.wit.com/apps/go-clone              # 'git clone' go-clone
`
}

func (args) Appname() string {
	return ARGNAME
}

func (a args) DoAutoComplete(pb *argvpb.Argv) {
	// fmt.Fprintf(os.Stderr, "blah\n")
	// fmt.Fprintf(os.Stderr, "\n")
	if pb.Cmd == "" {
		pb.SendStrings([]string{"--dry-run", "--non-recursive", "--work", "--version"})
	} else {
		pb.SubCommand(pb.Goargs...)
	}
	os.Exit(0)
}