cli

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set by goreleaser at build time.

Functions

func Run

func Run(args []string, stdout io.Writer, stderr io.Writer) int

Run executes the CLI with the provided arguments.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App wires CLI output and API access.

func (*App) RenderCurrentWeather

func (a *App) RenderCurrentWeather(w *weathercli.CurrentWeather) error

RenderCurrentWeather outputs current weather in human or JSON format.

func (*App) RenderForecast

func (a *App) RenderForecast(f *weathercli.Forecast) error

RenderForecast outputs forecast in human or JSON format.

func (*App) RenderLocations

func (a *App) RenderLocations(locations []weathercli.Location) error

RenderLocations outputs location search results.

type Color

type Color struct {
	// contains filtered or unexported fields
}

Color wraps color output helpers.

func NewColor

func NewColor(enabled bool) Color

NewColor creates a color helper.

func (Color) Blue

func (c Color) Blue(s string) string

Blue returns blue text.

func (Color) Bold

func (c Color) Bold(s string) string

Bold returns bold text.

func (Color) Cyan

func (c Color) Cyan(s string) string

Cyan returns cyan text.

func (Color) Green

func (c Color) Green(s string) string

Green returns green text.

func (Color) Magenta

func (c Color) Magenta(s string) string

Magenta returns magenta text.

func (Color) Red

func (c Color) Red(s string) string

Red returns red text.

func (Color) Yellow

func (c Color) Yellow(s string) string

Yellow returns yellow text.

type CurrentCmd

type CurrentCmd struct {
	Location string `arg:"" name:"location" help:"Location name (e.g. 'New York', 'London, UK')."`
}

CurrentCmd gets current weather.

func (*CurrentCmd) Run

func (c *CurrentCmd) Run(app *App) error

Run for CurrentCmd.

type ForecastCmd

type ForecastCmd struct {
	Location string `arg:"" name:"location" help:"Location name (e.g. 'Paris', 'Tokyo, Japan')."`
	Days     int    `help:"Number of forecast days (1-16)." default:"7"`
	Hourly   bool   `help:"Show hourly forecast instead of daily."`
	Hours    int    `help:"Number of hours for hourly forecast (1-384)." default:"24"`
}

ForecastCmd gets weather forecast.

func (*ForecastCmd) Run

func (c *ForecastCmd) Run(app *App) error

Run for ForecastCmd.

type GlobalOptions

type GlobalOptions struct {
	BaseURL    string        `help:"Weather API base URL." env:"WEATHER_BASE_URL" default:"https://api.open-meteo.com/v1"`
	GeoBaseURL string        `help:"Geocoding API base URL." env:"WEATHER_GEO_BASE_URL" default:"https://geocoding-api.open-meteo.com/v1"`
	Timeout    time.Duration `help:"HTTP timeout." default:"10s"`
	JSON       bool          `help:"Output JSON."`
	NoColor    bool          `help:"Disable color output."`
	Verbose    bool          `help:"Verbose logging."`
	Version    VersionFlag   `name:"version" help:"Print version and exit."`
}

GlobalOptions are flags shared by all commands.

type Root

type Root struct {
	Global   GlobalOptions `embed:""`
	Current  CurrentCmd    `cmd:"" help:"Get current weather for a location."`
	Forecast ForecastCmd   `cmd:"" help:"Get weather forecast for a location."`
	Search   SearchCmd     `cmd:"" help:"Search for location coordinates."`
}

Root defines the CLI command tree.

type SearchCmd

type SearchCmd struct {
	Query string `arg:"" name:"query" help:"Location search query."`
	Limit int    `help:"Max results (1-10)." default:"5"`
}

SearchCmd searches for locations.

func (*SearchCmd) Run

func (c *SearchCmd) Run(app *App) error

Run for SearchCmd.

type VersionFlag

type VersionFlag string

VersionFlag is a custom kong flag for --version.

func (VersionFlag) BeforeApply

func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error

BeforeApply prints the version and exits.

func (VersionFlag) Decode

func (v VersionFlag) Decode(_ *kong.DecodeContext) error

Decode is a no-op for the boolean version flag.

func (VersionFlag) IsBool

func (v VersionFlag) IsBool() bool

IsBool marks the version flag as boolean.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL