Files
zeromesh/cmd/zeromesh-cli/main.go

37 lines
706 B
Go

package main
import (
"flag"
"fmt"
"os"
"zeromesh/internal/identity"
)
func main() {
var cmd string
flag.StringVar(&cmd, "cmd", "", "command: gen-identity | show-identity")
flag.Parse()
switch cmd {
case "gen-identity":
id := identity.Generate()
data, _ := id.Serialize()
fmt.Println(data)
case "show-identity":
idPath := flag.Arg(0)
if idPath == "" {
idPath = "./data/agent.identity"
}
id, err := identity.LoadOrGenerate(idPath)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Address: %s\n", id.Address)
fmt.Printf("Public: %s\n", id.PublicKeyHex())
default:
fmt.Println("Usage: zeromesh-cli -cmd=gen-identity")
}
}