diff options
Diffstat (limited to 'argv.go')
| -rw-r--r-- | argv.go | 52 |
1 files changed, 10 insertions, 42 deletions
@@ -6,14 +6,9 @@ package main */ import ( - "fmt" "os" - "strconv" - "strings" - "time" - "go.wit.com/lib/gui/prep" - "go.wit.com/lib/gui/shell" + "go.wit.com/lib/protobuf/argvpb" ) var argv args @@ -59,48 +54,21 @@ func (args) Buildtime() (string, string) { return BUILDTIME, VERSION } -func (args) Version() string { - parts := strings.Split(BUILDTIME, ".") - if len(parts) == 1 { - // The input epoch seconds - // epochSeconds := int64(1758646486) - num, err := strconv.Atoi(BUILDTIME) - epochSeconds := int64(num) - if err == nil { - - // 1. Convert the epoch seconds to a time.Time object. - // time.Unix() creates the time in the UTC timezone by default. - t := time.Unix(epochSeconds, 0) - - // 2. Convert the UTC time to the computer's local timezone. - localTime := t.Local() - - // 3. Print the result. The default format is clear and includes the timezone. - // fmt.Println("Default format:", localTime) - // For a more human-friendly format, use the Format() method. - // Go uses a special reference time for formatting: Mon Jan 2 15:04:05 2006 MST - // You lay out your desired format using these specific numbers. - // formattedString := localTime.Format("Monday, January 2, 2006 at 3:04:05 PM (MST)") - // fmt.Println(" Custom format:", formattedString) - - // now := time.Now() - // dur := time.Since(localTime) - BUILDTIME = fmt.Sprintf("%s age(%v)", localTime.String(), shell.FormatDuration(time.Since(localTime))) - } - } - - return ARGNAME + " " + VERSION + " Built on " + BUILDTIME -} - /* handles shell autocomplete */ -func (a args) DoAutoComplete(pb *prep.Auto) { +func (args) Version() string { + return argvpb.StandardVersion(ARGNAME, VERSION, BUILDTIME) +} + +// sends the strings to bash or zsh that will be your options +func (a args) SendCompletionStrings(pb *argvpb.Argv) { if pb.Cmd == "" { - pb.Autocomplete3([]string{"--bash", "repos", "gui", "patches", "--daemon", "missing"}) + base := []string{"--bash", "repos", "gui", "patches", "--daemon", "missing"} + pb.SendStrings(base) } else { - pb.SubCommand(pb.Argv...) + pb.SubCommand(pb.Goargs...) } os.Exit(0) } |
