summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bash.orig.go8
-rw-r--r--complete.go49
-rw-r--r--exit.go6
3 files changed, 49 insertions, 14 deletions
diff --git a/bash.orig.go b/bash.orig.go
index ecd6bdd..7d431cc 100644
--- a/bash.orig.go
+++ b/bash.orig.go
@@ -8,7 +8,7 @@ import (
"strings"
"go.wit.com/dev/alexflint/arg"
- "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/config"
)
/*
@@ -40,7 +40,7 @@ type AutoArgs struct {
// print out auto complete debugging info
func (pb *Auto) PrintDebug() {
dur := pb.Duration.AsDuration()
- pb.Debugf("AUTOCOMPLETE: arg0='%s' arg1='%s' partial='%s' cmd='%s' age=%s argv=%v\n", pb.Arg0, pb.Arg1, pb.Partial, pb.Cmd, shell.FormatDuration(dur), pb.Argv)
+ pb.Debugf("AUTOCOMPLETE: arg0='%s' arg1='%s' partial='%s' cmd='%s' age=%s argv=%v\n", pb.Arg0, pb.Arg1, pb.Partial, pb.Cmd, config.FormatDuration(dur), pb.Argv)
}
func (pb *Auto) WriteHelp() {
@@ -93,12 +93,12 @@ func doBash(argname string) {
os.Exit(0)
}
filename := filepath.Join(homeDir, ".local/share/bash-completion/completions", argname)
- if shell.Exists(filename) {
+ if config.Exists(filename) {
log.Println(filename, "file already exists")
os.Exit(0)
}
basedir, _ := filepath.Split(filename)
- if !shell.IsDir(basedir) {
+ if !config.IsDir(basedir) {
os.MkdirAll(basedir, os.ModePerm)
}
diff --git a/complete.go b/complete.go
index bd9d46e..905ba8d 100644
--- a/complete.go
+++ b/complete.go
@@ -11,7 +11,7 @@ import (
"time"
"go.wit.com/dev/alexflint/arg"
- "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/config"
"go.wit.com/log"
durationpb "google.golang.org/protobuf/types/known/durationpb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
@@ -40,7 +40,7 @@ func (pb *Auto) doHandlePB() error {
cmd := fmt.Sprintf("cmd='%s'", found.Cmd)
arglast := fmt.Sprintf("last='%s'", found.Last)
partial := fmt.Sprintf("p='%s'", found.Partial)
- age := fmt.Sprintf("age='%-6.6s'", shell.FormatDuration(dur))
+ age := fmt.Sprintf("age='%-6.6s'", config.FormatDuration(dur))
pb.Debugf("AUTO HISTORY: %s %-18.18s %-18.18s %-12.12s argv='%v' goargs='%v'", age, cmd, arglast, partial, found.Argv, found.Goargs)
last = found
}
@@ -149,7 +149,7 @@ func (pb *Auto) Autocomplete2(sendthis string) {
if dur < time.Millisecond*200 {
pb.Debug = true
/*
- pb.Debugf("TODO: show extended help here '%s' '%s' %v dur=%v\n", pb.Arg0, pb.Arg1, pb.Argv, shell.FormatDuration(dur))
+ pb.Debugf("TODO: show extended help here '%s' '%s' %v dur=%v\n", pb.Arg0, pb.Arg1, pb.Argv, config.FormatDuration(dur))
pb.PrintDebug()
fmt.Println(" ")
*/
@@ -393,12 +393,12 @@ func doBash(argname string) {
os.Exit(0)
}
filename := filepath.Join(homeDir, ".local/share/bash-completion/completions", argname)
- if shell.Exists(filename) {
+ if config.Exists(filename) {
log.Fprintln(os.Stderr, "# file already exists", filename)
// os.Exit(0)
}
basedir, _ := filepath.Split(filename)
- if !shell.IsDir(basedir) {
+ if !config.IsDir(basedir) {
os.MkdirAll(basedir, os.ModePerm)
}
@@ -451,11 +451,46 @@ func (pb *Auto) getVersion() string {
// now := time.Now()
// dur := time.Since(localTime)
- // BUILDTIME = fmt.Sprintf("%s age(%v)", localTime.String(), , shell.FormatDuration(time.Since(localTime)))
- stamp := log.Sprintf("Built %s Age(%s)", localTime.Format("2006-01-02 15:04"), shell.FormatDuration(time.Since(localTime)))
+ // BUILDTIME = fmt.Sprintf("%s age(%v)", localTime.String(), , config.FormatDuration(time.Since(localTime)))
+ stamp := log.Sprintf("Built %s Age(%s)", localTime.Format("2006-01-02 15:04"), config.FormatDuration(time.Since(localTime)))
return fmt.Sprintf("%s %s %s", pb.Argname, VERSION, stamp)
}
}
return fmt.Sprintf("%s %s Built on %s", pb.Argname, VERSION, BUILDTIME)
}
+
+func StandardVersion(ARGNAME, VERSION, BUILDTIME string) 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(), , config.FormatDuration(time.Since(localTime)))
+ stamp := log.Sprintf("Built %s Age(%s)", localTime.Format("2006-01-02 15:04"), config.FormatDuration(time.Since(localTime)))
+ return fmt.Sprintf("%s %s %s", ARGNAME, VERSION, stamp)
+ }
+ }
+
+ return fmt.Sprintf("%s %s Built on %s", ARGNAME, VERSION, BUILDTIME)
+}
diff --git a/exit.go b/exit.go
index 5c8047d..c6390b5 100644
--- a/exit.go
+++ b/exit.go
@@ -4,7 +4,7 @@ import (
"os"
"time"
- "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/config"
"go.wit.com/log"
)
@@ -12,7 +12,7 @@ import (
func (pb *Auto) GoodExit(msg string) {
dur := time.Since(pb.Ctime.AsTime())
- log.Infof("%s: %s (%s)\n", pb.Argname, msg, shell.FormatDuration(dur))
+ log.Infof("%s: %s (%s)\n", pb.Argname, msg, config.FormatDuration(dur))
os.Exit(0)
}
@@ -21,6 +21,6 @@ func (pb *Auto) BadExit(msg string, err error) {
log.Info(err)
}
dur := time.Since(pb.Ctime.AsTime())
- log.Infof("%s: %s (%s)\n", pb.Argname, msg, shell.FormatDuration(dur))
+ log.Infof("%s: %s (%s)\n", pb.Argname, msg, config.FormatDuration(dur))
os.Exit(-1)
}