package cmd
import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
"skraak/tools"
)
// RunTime handles the "time" subcommand
func RunTime(args []string) {
fs := flag.NewFlagSet("time", flag.ExitOnError)
fs.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: skraak time\n\n")
fmt.Fprintf(os.Stderr, "Get the current system time with timezone information.\n\n")
fmt.Fprintf(os.Stderr, "Examples:\n")
fmt.Fprintf(os.Stderr, " skraak time\n")
fmt.Fprintf(os.Stderr, " skraak time | jq '.iso'\n")
}
if err := fs.Parse(args); err != nil {
os.Exit(1)
}
// Get current time
output, err := tools.GetCurrentTime(context.Background(), tools.GetCurrentTimeInput{})
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
// Output as JSON
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(output)
}