summaryrefslogtreecommitdiff
path: root/argv.custom.go
diff options
context:
space:
mode:
Diffstat (limited to 'argv.custom.go')
-rw-r--r--argv.custom.go103
1 files changed, 103 insertions, 0 deletions
diff --git a/argv.custom.go b/argv.custom.go
new file mode 100644
index 0000000..5913868
--- /dev/null
+++ b/argv.custom.go
@@ -0,0 +1,103 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+import (
+ "os"
+
+ "go.wit.com/gui"
+ "go.wit.com/lib/debugger"
+ "go.wit.com/lib/fhelp"
+ "go.wit.com/lib/protobuf/argvpb"
+)
+
+// sent via -ldflags // is there a better way?
+var VERSION string
+var BUILDTIME string
+
+// used for shell auto completion
+var APPNAME string = "forge"
+
+func (args) Buildtime() (string, string) {
+ return BUILDTIME, VERSION
+}
+
+func (a args) Description() string {
+ // doHelp()
+
+ return `
+forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
+
+ forge only executes the 'git' command. Everything it does, you can run by hand with 'git'.
+
+ Orginally written to maintain the +50 GO git repositories for the WIT Private Cloud
+`
+}
+
+func ifBlank(arg string) bool {
+ if arg == "''" {
+ // if empty, the user has not typed something
+ return true
+ }
+ return false
+}
+
+func (args) Appname() string {
+ return APPNAME
+}
+
+// arg.Register(&argGui)
+// log.Info("ArgvGui() started")
+func (args) ArgvGui() error {
+ me.myGui = fhelp.Gui() // adds the GUI package argv support
+ me.origGui = gui.New()
+ return nil
+}
+
+func (args) ArgvDebugger() bool {
+ debugger.InitDebugger()
+ // me.myGui = gui.Init()
+ return true
+}
+
+func (args) Examples() string {
+ var out string
+ out += "forge show # show the state of all your repos\n"
+ out += "forge normal # the defaults for 'normal' forge distributed development\n"
+ out += " # it will makes a user branch in every git repo\n"
+ out += "forge clean # removes changes forge might have made\n"
+ out += " # purges all untracked git files, etc\n"
+ out += "forge pull --force # 'git pull' on all repos\n"
+ out += "forge commit --al # 'git commit' in every dirty repo\n"
+ out += "forge merge --all # 'git merge' all patches to devel & master\n"
+ out += "forge add # scan your current directory for all git repos\n"
+ return out
+}
+
+func (args) Version() string {
+ // log.Info(me.sh.Version())
+ // return APPNAME + " " + VERSION + " Built on " + BUILDTIME
+ return argvpb.StandardVersion(APPNAME, VERSION, BUILDTIME)
+}
+
+// matches
+func (c CleanCmd) Match(partial string) []string {
+ // return repos here
+ return []string{"go.wit.com/apps/forge", "go.wit.com/apps/virtigo"}
+}
+
+// sends the strings to bash or zsh that will be your options
+func (a args) SendCompletionStrings(pb *argvpb.Argv) {
+ if pb.Cmd == "" {
+ // these are base autocomplete strings
+ matches := []string{"clean", "commit", "merge", "patch", "normal", "pull", "rebuild", "generate"}
+ matches = append(matches, "show", "add", "fixer", "dev", "verify", "mode", "gui", "whatchanged")
+ matches = append(matches, "--version", "--force", "--all")
+ pb.SendStrings(matches)
+ } else {
+ // autogenerate the strings for the subcommand using github.com/alexflint/go-arg
+ pb.GenerateSubCommandStrings(pb.Goargs...)
+ }
+ os.Exit(0)
+}