summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makeAutocompleteFiles.go16
-rw-r--r--sendStrings.go7
-rw-r--r--version.go71
3 files changed, 24 insertions, 70 deletions
diff --git a/makeAutocompleteFiles.go b/makeAutocompleteFiles.go
index 647abe3..57bf391 100644
--- a/makeAutocompleteFiles.go
+++ b/makeAutocompleteFiles.go
@@ -12,6 +12,22 @@ import (
"go.wit.com/log"
)
+func detectShell() string {
+ // Zsh sets ZSH_VERSION. We use os.LookupEnv which returns a boolean
+ // indicating if the variable is present.
+ if _, ok := os.LookupEnv("ZSH_VERSION"); ok {
+ return "zsh"
+ }
+
+ // Bash sets BASH_VERSION.
+ if _, ok := os.LookupEnv("BASH_VERSION"); ok {
+ return "bash"
+ }
+
+ // Fallback if neither is found.
+ return "unknown"
+}
+
// makes a autocomplete file for your command
func makeAutocompleteFiles(argname string) {
fmt.Println(makeBashCompletionText2(argname))
diff --git a/sendStrings.go b/sendStrings.go
index 19ccc30..2fe1977 100644
--- a/sendStrings.go
+++ b/sendStrings.go
@@ -1,6 +1,8 @@
package prep
-// initializes logging and command line options
+// sends the autocomplete strings to the shell
+// also where custom strings are pulled in from the application
+// calls into go-args for strings parsed by MustParse()
import (
"fmt"
@@ -21,11 +23,12 @@ func (pb *Auto) Autocomplete2(sendthis string) {
pb.SendStrings(strings.Split(sendthis, " "))
}
+// the application must send a string "help run list"
func (pb *Auto) SendString(sendthis string) {
pb.SendStrings(strings.Split(sendthis, " "))
}
-// this is the user's application sending us strings we need to send to bash
+// the application must send an array []string{"help", "run", "list"}
func (pb *Auto) SendStrings(parts []string) {
dur := pb.Duration.AsDuration()
if dur < time.Millisecond*200 {
diff --git a/version.go b/version.go
index 0b5455e..0b923e5 100644
--- a/version.go
+++ b/version.go
@@ -5,11 +5,8 @@ package prep
import (
"fmt"
"os"
- "strconv"
- "strings"
- "time"
- "go.wit.com/lib/config"
+ "go.wit.com/lib/cobol"
"go.wit.com/log"
)
@@ -28,71 +25,9 @@ func (pb *Auto) getVersion() string {
}
BUILDTIME, VERSION := myAuto.buildtime()
- 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", pb.Argname, VERSION, stamp)
- }
- }
-
- return fmt.Sprintf("%s %s Built on %s", pb.Argname, VERSION, BUILDTIME)
+ return fmt.Sprintf("%s %s Built on %s", pb.Argname, VERSION, cobol.Time(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)
+ return fmt.Sprintf("%s %s Built on %s", ARGNAME, VERSION, cobol.Time(BUILDTIME))
}