From b09b86009ecb17c171aab400af73a568d084f49e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 23 Sep 2025 12:14:26 -0500 Subject: some fun stuff --- argv.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'argv.go') diff --git a/argv.go b/argv.go index ae0366e..7baf9c8 100644 --- a/argv.go +++ b/argv.go @@ -8,6 +8,12 @@ package main import ( "fmt" "os" + "strconv" + "strings" + "time" + + "go.wit.com/lib/gui/prep" + "go.wit.com/lib/gui/shell" ) var argv args @@ -29,17 +35,51 @@ type args struct { type EmptyCmd struct { } +func (args) Appname() string { + return ARGNAME +} + 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 } -func (a args) DoAutoComplete(argv []string) { - // argv.doBashHelp() - switch argv[0] { - case "merge": - fmt.Println("--force") +func (a args) DoAutoComplete(pb *prep.Auto) { + switch pb.Cmd { + case "list": + pb.Autocomplete2("--missing") + case "clean": + pb.Autocomplete2("") default: - fmt.Println("list merge repos") + pb.Autocomplete2("list clean") } os.Exit(0) } -- cgit v1.2.3