some fun stuff

This commit is contained in:
Jeff Carr 2025-09-23 12:14:26 -05:00
parent 1f22b771c3
commit b09b86009e
5 changed files with 64 additions and 22 deletions

View File

@ -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 \

52
argv.go
View File

@ -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)
}

View File

@ -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()
}
/*
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() {
log.Info("Info", pset.Name, pset.Uuid)
for i, patch := range pset.Patches.Patches {
log.Info("\t", i, patch.CommitHash, patch.Namespace)
for patch := range pset.Patches.IterAll() {
log.Info("\t", patch.CommitHash, patch.PatchId, patch.Namespace)
}
}
*/
return nil
}

View File

@ -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.auto = prep.Bash3(&argv) // this line should be: prep.Bash(&argv)
me.forge = forgepb.InitByAppname(ARGNAME)

View File

@ -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
}