Fork channel

Create a new channel as a copy of main.

Rename channel

Rename main to:

Delete channel

Delete main? This cannot be undone.

time.go
package cmd

import (
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"os"

	"skraak/tools"
)

// RunTime handles the "time" subcommand
//
// JSON output schema:
//
//	{
//	  "time": string,     // Current system time in RFC3339 format
//	  "timezone": string, // System timezone
//	  "unix": int         // Unix timestamp in seconds
//	}
func RunTime(args []string) error {
	fs := flag.NewFlagSet("time", flag.ExitOnError)

	fs.Usage = usagePrinter(fs,
		"skraak time",
		"Get the current system time with timezone information.",
		"skraak time",
		"skraak time | jq '.iso'",
	)

	if err := fs.Parse(args); err != nil {
		return fmt.Errorf("parsing flags: %w", err)
	}

	output, err := tools.GetCurrentTime(context.Background(), tools.GetCurrentTimeInput{})
	if err != nil {
		return fmt.Errorf("getting time: %w", err)
	}

	// Output as JSON
	enc := json.NewEncoder(os.Stdout)
	enc.SetIndent("", "  ")
	if err := enc.Encode(output); err != nil {
		return fmt.Errorf("encoding output: %w", err)
	}
	return nil
}