Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f02f64f82a | |||
| 75e398b2fe | |||
| 16cf2f1941 | |||
| 6fae590d2e |
@@ -1,7 +1,7 @@
|
|||||||
BINARY ?= htsy
|
BINARY ?= htsy-cli
|
||||||
VERSION ?= dev
|
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo dev)
|
||||||
LDFLAGS := -s -w -X main.version=$(VERSION)
|
LDFLAGS := -s -w -X main.version=$(VERSION)
|
||||||
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64
|
PLATFORMS := darwin/amd64 darwin/arm64 windows/amd64
|
||||||
|
|
||||||
.PHONY: test build release clean
|
.PHONY: test build release clean
|
||||||
|
|
||||||
@@ -13,17 +13,17 @@ build:
|
|||||||
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/$(BINARY) .
|
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/$(BINARY) .
|
||||||
|
|
||||||
release: clean test
|
release: clean test
|
||||||
mkdir -p dist
|
mkdir -p bin
|
||||||
for platform in $(PLATFORMS); do \
|
for platform in $(PLATFORMS); do \
|
||||||
GOOS=$${platform%/*}; \
|
GOOS=$${platform%/*}; \
|
||||||
GOARCH=$${platform#*/}; \
|
GOARCH=$${platform#*/}; \
|
||||||
EXT=""; \
|
EXT=""; \
|
||||||
if [ "$$GOOS" = "windows" ]; then EXT=".exe"; fi; \
|
if [ "$$GOOS" = "windows" ]; then EXT=".exe"; fi; \
|
||||||
OUT="dist/$(BINARY)_$${GOOS}_$${GOARCH}$${EXT}"; \
|
OUT="bin/$(BINARY)_$${GOOS}_$${GOARCH}$${EXT}"; \
|
||||||
echo "building $$OUT"; \
|
echo "building $$OUT"; \
|
||||||
CGO_ENABLED=0 GOOS=$$GOOS GOARCH=$$GOARCH go build -trimpath -ldflags "$(LDFLAGS)" -o "$$OUT" .; \
|
CGO_ENABLED=0 GOOS=$$GOOS GOARCH=$$GOARCH go build -trimpath -ldflags "$(LDFLAGS)" -o "$$OUT" .; \
|
||||||
done
|
done
|
||||||
cd dist && shasum -a 256 * > checksums.txt
|
cd bin && shasum -a 256 * > checksums.txt
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin dist
|
rm -rf bin dist
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Release builds override this with: -ldflags="-X main.version=<tag>".
|
||||||
var version = "dev"
|
var version = "dev"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -44,7 +45,7 @@ func run(args []string) error {
|
|||||||
case "config":
|
case "config":
|
||||||
return runConfig(args[1:])
|
return runConfig(args[1:])
|
||||||
case "version", "--version", "-v":
|
case "version", "--version", "-v":
|
||||||
fmt.Printf("htsy %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH)
|
fmt.Printf("htsy-cli %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH)
|
||||||
return nil
|
return nil
|
||||||
case "help", "--help", "-h":
|
case "help", "--help", "-h":
|
||||||
printUsage()
|
printUsage()
|
||||||
@@ -369,7 +370,7 @@ func runCall(args []string) error {
|
|||||||
token = cfg.Token
|
token = cfg.Token
|
||||||
}
|
}
|
||||||
if !noAuth && token == "" {
|
if !noAuth && token == "" {
|
||||||
return fmt.Errorf("not logged in; run htsy login first or pass --token")
|
return fmt.Errorf("not logged in; run htsy-cli login first or pass --token")
|
||||||
}
|
}
|
||||||
body, err := readJSONData(data)
|
body, err := readJSONData(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -570,18 +571,18 @@ func printObject(value any) error {
|
|||||||
|
|
||||||
func printUsage() {
|
func printUsage() {
|
||||||
fmt.Println(strings.TrimSpace(`
|
fmt.Println(strings.TrimSpace(`
|
||||||
htsy 是海豚私域接口命令行工具。
|
htsy-cli 是海豚私域接口命令行工具。
|
||||||
|
|
||||||
用法:
|
用法:
|
||||||
htsy login --username USER --password PASS [--base-url URL]
|
htsy-cli login --username USER --password PASS [--base-url URL]
|
||||||
htsy account-login --phone PHONE --password PASS
|
htsy-cli account-login --phone PHONE --password PASS
|
||||||
htsy send-code --phone PHONE --scene register
|
htsy-cli send-code --phone PHONE --scene register
|
||||||
htsy register --username PHONE --password PASS --sms-code CODE [--invite-token TOKEN]
|
htsy-cli register --username PHONE --password PASS --sms-code CODE [--invite-token TOKEN]
|
||||||
htsy call /api/account/user/info -d '{}'
|
htsy-cli call /api/account/user/info -d '{}'
|
||||||
htsy status
|
htsy-cli status
|
||||||
htsy logout
|
htsy-cli logout
|
||||||
htsy config path
|
htsy-cli config path
|
||||||
htsy config set-base-url https://htsy-gateway.cpshelp.cn
|
htsy-cli config set-base-url https://htsy-gateway.cpshelp.cn
|
||||||
|
|
||||||
配置:
|
配置:
|
||||||
登录信息会保存到当前用户主目录下的 ~/.htsy/config.json。
|
登录信息会保存到当前用户主目录下的 ~/.htsy/config.json。
|
||||||
|
|||||||
Reference in New Issue
Block a user