[+] improve help prompts

Signed-off-by: Seven SUN <i@sunyz.net>
This commit is contained in:
Seven SUN 2025-01-25 21:16:57 +08:00
parent adbc78bbf7
commit f6252ef22d
Signed by: realSunyz
SSH Key Fingerprint: SHA256:5dk3slVnWtJYlwrnURrUYXoimuSx8Vi9pbs4n3XoGH0

44
src/main.go Normal file
View File

@ -0,0 +1,44 @@
package main
import (
"fmt"
"os"
"github.com/realsunyz/geofeed-tools/plugin/validate"
)
const version = "1.0.0"
var help = fmt.Sprintf(
"Geofeed Tools Version %s (compiled to binary)\n"+
"Usage: ./geofeed-tools [flags] [filepath]\n\n"+
"Flags:\n"+
" -h Show this help message\n"+
" -v Validate a geofeed file\n", version)
func main() {
if len(os.Args) < 2 {
fmt.Print(help)
os.Exit(1)
}
flag := os.Args[1]
if flag == "-h" {
fmt.Print(help)
os.Exit(1)
} else if flag == "-v" {
if len(os.Args) != 3 {
fmt.Println(
"Usage: ./geofeed-tools -v [filepath]")
os.Exit(1)
}
filePath := os.Args[2]
validate.Execute(filePath)
} else {
fmt.Printf(
"Error: Invalid flag \"%s\"\n"+
"Use \"./geofeed-tools -h\" to see available flags.\n", os.Args[1])
os.Exit(1)
}
}