diff --git a/Makefile b/Makefile index fd173d8..3ce5b4a 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ COMMIT = `git rev-parse --short HEAD || echo "$COMMIT"` VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION"` build: - go build $(GOFLAGS) ./cmd/stcli - strip stcli + go build $(GOFLAGS) ./cmd/suwako + strip suwako clean: - rm -f stcli + rm -f suwako install: - install -Dm0755 stcli ${PREFIX}/bin/stcli + install -Dm0755 suwako ${PREFIX}/bin/suwako uninstall: - rm -f ${PREFIX}/bin/stcli - rm -f ${PREFIX}/share/man/man1/stcli.1 + rm -f ${PREFIX}/bin/suwako + rm -f ${PREFIX}/share/man/man1/suwako.1 diff --git a/README b/README index 512d56b..bfc355d 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -stcli +suwako ===== Command-line client for SimplyTranslate in Go. diff --git a/go.mod b/go.mod index 8a1497e..022ec39 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module marisa.chaotic.ninja/stcli +module marisa.chaotic.ninja/suwako go 1.18 diff --git a/stcli.1 b/stcli.1 deleted file mode 100644 index 08f55fd..0000000 --- a/stcli.1 +++ /dev/null @@ -1,41 +0,0 @@ -.Dd Chaos 42, 3189 -.Dt STCLI 1 -.Os -.Sh NAME -.Nm stcli-go -.Nd Command-line client for SimplyTranslate in Go -.Sh SYNOPSIS -.Nm -.Fl e Ar engine -.Fl f Ar from -.Fl i Ar instance -.Fl I Ar input -.Fl t Ar to -.Sh DESCRIPTION -Self-explanatory, besides, this was made as -a rewrite from a shell script that had curl -and awk for dependencies. It fully serves -as a drop-in replacement. -.Sh USAGE -.Bl -tag -width 11n -compact -.It -e -Translation engine to use -.It -f -Input language to translate from -.It -i -Instance to use -.It -I -Text to translate -.It -t -Target language to translate to -.El -.Sh AUTHORS -.An Aoi K. Aq Mt koizumi.aoi@chaotic.ninja -.Pp -.An Czar of KST Aq Mt czar@kalli.st -.Pp -.An Shokara Kou Aq Mt kou@clearnet.fqdn -.Pp -.An Baobab Aq Mt baobab@honeypot.im -.Sh BUGS -None so far diff --git a/version.go b/version.go new file mode 100644 index 0000000..144213d --- /dev/null +++ b/version.go @@ -0,0 +1,50 @@ +package suwako + +import ( + "fmt" + "runtime/debug" + "strings" +) + +const ( + defaultVersion = "0.0.0" + defaultCommit = "HEAD" + defaultBuild = "0000-01-01:00:00+00:00" +) + +var ( + // Version is the tagged release version in the form .. + // following semantic versioning and is overwritten by the build system. + Version = defaultVersion + + // Commit is the commit sha of the build (normally from Git) and is overwritten + // by the build system. + Commit = defaultCommit + + // Build is the date and time of the build as an RFC3339 formatted string + // and is overwritten by the build system. + Build = defaultBuild +) + +// FullVersion display the full version and build +func FullVersion() string { + var sb strings.Builder + + isDefault := Version == defaultVersion && Commit == defaultCommit && Build == defaultBuild + + if !isDefault { + sb.WriteString(fmt.Sprintf("%s@%s %s", Version, Commit, Build)) + } + + if info, ok := debug.ReadBuildInfo(); ok { + if isDefault { + sb.WriteString(fmt.Sprintf(" %s", info.Main.Version)) + } + sb.WriteString(fmt.Sprintf(" %s", info.GoVersion)) + if info.Main.Sum != "" { + sb.WriteString(fmt.Sprintf(" %s", info.Main.Sum)) + } + } + + return sb.String() +}