summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go32
-rw-r--r--main.go15
2 files changed, 6 insertions, 41 deletions
diff --git a/argv.go b/argv.go
index 500229e..a203c8e 100644
--- a/argv.go
+++ b/argv.go
@@ -25,8 +25,6 @@ type args struct {
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"`
- Bash bool `arg:"--bash" help:"generate bash completion"`
- BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
}
type EmptyCmd struct {
@@ -40,37 +38,13 @@ func init() {
arg.MustParse(&argv)
}
-// prints help to STDERR // TODO: move everything below this to go-args
-func (args) doBashHelp() {
- if len(argv.BashAuto) < 2 {
- fmt.Fprintf(os.Stderr, "something went wrong with the GO args autocomplete in %s\n", ARGNAME)
- return
- }
- if argv.BashAuto[1] != "''" {
- // if this is not blank, then the user has typed something
- return
- }
- if argv.BashAuto[0] != ARGNAME {
- fmt.Fprintln(os.Stderr, argv.BashAuto[0])
- // if this is not the name of the command, the user already started doing something
- return
- }
- if argv.BashAuto[0] == ARGNAME {
- me.pp.WriteHelp(os.Stderr)
- return
- }
- fmt.Fprintln(os.Stderr, "")
- fmt.Fprintln(os.Stderr, "something went wrong with the GO args package")
- fmt.Fprintln(os.Stderr, "")
-}
-
-func (args) doBashAuto() {
+func (a args) DoAutoComplete(argv []string) {
// argv.doBashHelp()
- switch argv.BashAuto[0] {
+ switch argv[0] {
case "merge":
fmt.Println("--force")
default:
- if argv.BashAuto[0] == ARGNAME {
+ if argv[0] == ARGNAME {
// list the subcommands here
fmt.Println("list merge")
}
diff --git a/main.go b/main.go
index bdd834d..f883dbf 100644
--- a/main.go
+++ b/main.go
@@ -8,8 +8,7 @@ import (
"time"
"go.wit.com/dev/alexflint/arg"
- "go.wit.com/gui"
- "go.wit.com/lib/fhelp"
+ "go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
@@ -28,18 +27,10 @@ var LIBDIR string = "/var/lib/forged/" // need to deprecate this
func main() {
me = new(mainType)
- gui.InitArg()
+ prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: this line should be: prep.Bash(argv)
+ me.myGui = prep.Gui() // prepares the GUI package for go-args
me.pp = arg.MustParse(&argv)
- if argv.Bash {
- fhelp.DoBash(ARGNAME)
- os.Exit(0)
- }
- if len(argv.BashAuto) != 0 {
- argv.doBashAuto()
- os.Exit(0)
- }
-
if argv.Hostname != "" {
HOSTNAME = argv.Hostname
}