Long live Touhou

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/suwako/trunk@13 0b558ee1-521d-8b46-a41b-40029c97c055
This commit is contained in:
yakumo.izuru 2023-04-08 01:15:52 +00:00
parent 393a3db9bc
commit eb8fed77a3
5 changed files with 58 additions and 49 deletions

View File

@ -10,12 +10,12 @@ COMMIT = `git rev-parse --short HEAD || echo "$COMMIT"`
VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION"` VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION"`
build: build:
go build $(GOFLAGS) ./cmd/stcli go build $(GOFLAGS) ./cmd/suwako
strip stcli strip suwako
clean: clean:
rm -f stcli rm -f suwako
install: install:
install -Dm0755 stcli ${PREFIX}/bin/stcli install -Dm0755 suwako ${PREFIX}/bin/suwako
uninstall: uninstall:
rm -f ${PREFIX}/bin/stcli rm -f ${PREFIX}/bin/suwako
rm -f ${PREFIX}/share/man/man1/stcli.1 rm -f ${PREFIX}/share/man/man1/suwako.1

2
README
View File

@ -1,4 +1,4 @@
stcli suwako
===== =====
Command-line client for SimplyTranslate in Go. Command-line client for SimplyTranslate in Go.

2
go.mod
View File

@ -1,3 +1,3 @@
module marisa.chaotic.ninja/stcli module marisa.chaotic.ninja/suwako
go 1.18 go 1.18

41
stcli.1
View File

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

50
version.go Normal file
View File

@ -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 <major>.<minor>.<patch>
// 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()
}