From 72b5033710cede2d52c63afe3f6dec3d1e0f366b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 17 Oct 2025 16:29:56 -0500 Subject: renamed lib to argvpb --- argv.go | 52 ++++++++++------------------------------------------ doRepos.go | 9 ++++++--- main.go | 6 +++--- structs.go | 6 +++--- 4 files changed, 22 insertions(+), 51 deletions(-) diff --git a/argv.go b/argv.go index d73dbc0..9cfcd5d 100644 --- a/argv.go +++ b/argv.go @@ -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) } diff --git a/doRepos.go b/doRepos.go index f1e4ddc..29b8f3d 100644 --- a/doRepos.go +++ b/doRepos.go @@ -14,7 +14,8 @@ import ( func doRepos() error { if argv.Repos.List != nil { - me.forge.PrintForgedTable(me.forge.Repos) + footer := me.forge.Repos.PrintForgedTable() + log.Info("footer:", footer) // me.forge.PrintPullTable(me.forge.Repos) // return doReposList() return nil @@ -28,7 +29,8 @@ func doRepos() error { } found.Append(repo) } - me.forge.PrintForgedTable(found) + footer := found.PrintForgedTable() + log.Info("footer:", footer) return nil } @@ -135,7 +137,8 @@ func doRepos() error { found := gitpb.NewRepos() found.Append(me.forge.Repos.Repos[0]) found.Append(me.forge.Repos.Repos[1]) - me.forge.PrintForgedTable(found) + footer := found.PrintForgedTable() + log.Info(footer) return nil } diff --git a/main.go b/main.go index cbd9837..47d9a43 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( "path/filepath" "time" - "go.wit.com/lib/gui/prep" + "go.wit.com/lib/protobuf/argvpb" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -35,8 +35,8 @@ func saveMissing() error { func main() { me = new(mainType) - me.myGui = prep.Gui() // prepares the GUI package for go-args - me.auto = prep.Bash(&argv) // this line should be: prep.Bash(&argv) + me.myGui = argvpb.Gui() // prepares the GUI package for go-args + me.argv = argvpb.Autocomplete(&argv) // adds shell auto complete to go-args me.forge = forgepb.InitByFullpath("/etc/forged/forge.text") me.forge.Config.DumpENV() diff --git a/structs.go b/structs.go index 556a239..2bab68a 100644 --- a/structs.go +++ b/structs.go @@ -5,7 +5,7 @@ package main import ( "go.wit.com/dev/alexflint/arg" - "go.wit.com/lib/gui/prep" + "go.wit.com/lib/protobuf/argvpb" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" ) @@ -16,8 +16,8 @@ var me *mainType type mainType struct { pp *arg.Parser // for parsing the command line args. Yay to alexf lint! forge *forgepb.Forge // for holding the forge protobuf files - myGui *prep.GuiPrep // the gui toolkit handle - auto *prep.Auto // more experiments for bash handling + myGui *argvpb.GuiPrep // the gui toolkit handle + argv *argvpb.Argv // shell autocomplete configs *forgepb.ForgeConfigs // for holding the forge protobuf files missing *gitpb.Repos // repos we are missing } -- cgit v1.2.3