diff options
| author | Jeff Carr <[email protected]> | 2025-09-23 12:14:26 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-23 14:50:21 -0500 | 
| commit | b09b86009ecb17c171aab400af73a568d084f49e (patch) | |
| tree | af6767d0f83305b63b38bc544fe75c49d84a6492 | |
| parent | 1f22b771c3748b01d0d27574090fd2b6d4516182 (diff) | |
some fun stuff
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | argv.go | 52 | ||||
| -rw-r--r-- | doList.go | 19 | ||||
| -rw-r--r-- | main.go | 6 | ||||
| -rw-r--r-- | structs.go | 1 | 
5 files changed, 64 insertions, 22 deletions
@@ -1,10 +1,12 @@  .PHONY: build  VERSION = $(shell git describe --tags) -BUILDTIME = $(shell date +%Y.%m.%d_%H%M) +# BUILDTIME = $(shell date +%Y.%m.%d_%H%M) +BUILDTIME = $(shell date +%s) -all: build-verbose -	./forged list +all: build +	./forged --version +	# FORGE_VERBOSE=true ./forged list  build: goimports  	GO111MODULE=off go build \ @@ -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)  } @@ -6,20 +6,21 @@ import (  )  func doList() error { -  	log.Infof("do list here. Patchsets.Len()=%d\n", me.forge.Patchsets.Len())  	for pset := range me.forge.Patchsets.IterAll() {  		pset.PrintTable()  	} -	/* -		// show all the patchsets with Names -		for pset := range me.forge.Patchsets.IterAll() { -			log.Info("Info", pset.Name, pset.Uuid) -			for i, patch := range pset.Patches.Patches { -				log.Info("\t", i, patch.CommitHash, patch.Namespace) -			} +	return nil +} + +func doClean() error { +	log.Infof("clean Patchsets.Len()=%d\n", me.forge.Patchsets.Len()) +	// show all the patchsets with Names +	for pset := range me.forge.Patchsets.IterAll() { +		for patch := range pset.Patches.IterAll() { +			log.Info("\t", patch.CommitHash, patch.PatchId, patch.Namespace)  		} -	*/ +	}  	return nil  } @@ -6,7 +6,6 @@ import (  	"net/http"  	"time" -	"go.wit.com/dev/alexflint/arg"  	"go.wit.com/lib/fhelp"  	"go.wit.com/lib/gui/prep"  	"go.wit.com/lib/protobuf/forgepb" @@ -27,9 +26,8 @@ var LIBDIR string = "/var/lib/forged/" // need to deprecate this  func main() {  	me = new(mainType) -	prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: this line should be:  prep.Bash(argv) -	me.myGui = prep.Gui()                   // prepares the GUI package for go-args -	me.pp = arg.MustParse(&argv) +	me.myGui = prep.Gui()       // prepares the GUI package for go-args +	me.auto = prep.Bash3(&argv) // this line should be:  prep.Bash(&argv)  	me.forge = forgepb.InitByAppname(ARGNAME) @@ -16,5 +16,6 @@ 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  	configs *forgepb.ForgeConfigs // for holding the forge protobuf files  }  | 
