cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the CLI version string (set by GoReleaser).

Functions

func Run

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

Types

type App

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

type Color

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

Color renders ANSI color sequences.

func NewColor

func NewColor(enabled bool) Color

NewColor returns a color helper, optionally disabled.

func (Color) Bold

func (c Color) Bold(value string) string

Bold wraps a string in bold ANSI codes.

func (Color) Cyan

func (c Color) Cyan(value string) string

Cyan wraps a string in cyan ANSI codes.

func (Color) Dim

func (c Color) Dim(value string) string

Dim wraps a string in dim ANSI codes.

func (Color) Green

func (c Color) Green(value string) string

Green wraps a string in green ANSI codes.

func (Color) Yellow

func (c Color) Yellow(value string) string

Yellow wraps a string in yellow ANSI codes.

type DirectionsBicyclingCmd

type DirectionsBicyclingCmd struct {
	DirectionsCommon `embed:""`
	AlternativeRoute int `name:"alternative-route" help:"Number of alternative routes (1-3)."`
}

func (*DirectionsBicyclingCmd) Run

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

type DirectionsCmd

type DirectionsCmd struct {
	Driving     DirectionsDrivingCmd     `cmd:"" help:"Driving route."`
	Walking     DirectionsWalkingCmd     `cmd:"" help:"Walking route."`
	Bicycling   DirectionsBicyclingCmd   `cmd:"" help:"Bicycling route."`
	Electrobike DirectionsElectrobikeCmd `cmd:"" help:"Electric-bike route."`
	Transit     DirectionsTransitCmd     `cmd:"" help:"Public transit route."`
}

type DirectionsCommon

type DirectionsCommon struct {
	Origin      string `help:"Origin as 'longitude,latitude' or an address (geocoded if not coordinates)." required:""`
	Destination string `help:"Destination as 'longitude,latitude' or an address (geocoded if not coordinates)." required:""`
}

type DirectionsDrivingCmd

type DirectionsDrivingCmd struct {
	DirectionsCommon `embed:""`
	Strategy         string `help:"Routing strategy code (default 32 — high-accuracy recommendation)."`
	Waypoints        string `help:"Up to 16 waypoints, semicolon-separated; each is 'lng,lat' or an address (geocoded if not coordinates)."`
	Plate            string `help:"Vehicle plate for restriction-aware routing."`
}

func (*DirectionsDrivingCmd) Run

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

type DirectionsElectrobikeCmd

type DirectionsElectrobikeCmd struct {
	DirectionsCommon `embed:""`
	AlternativeRoute int `name:"alternative-route" help:"Number of alternative routes (1-3)."`
}

func (*DirectionsElectrobikeCmd) Run

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

type DirectionsTransitCmd

type DirectionsTransitCmd struct {
	DirectionsCommon `embed:""`
	Strategy         string `help:"Transit strategy code 0-8 (default 0 — recommended)."`
	AlternativeRoute int    `name:"alternative-route" help:"Number of alternative routes (1-10, default 5)."`
}

func (*DirectionsTransitCmd) Run

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

type DirectionsWalkingCmd

type DirectionsWalkingCmd struct {
	DirectionsCommon `embed:""`
	AlternativeRoute int `name:"alternative-route" help:"Number of alternative routes (1-3)."`
}

func (*DirectionsWalkingCmd) Run

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

type GlobalOptions

type GlobalOptions struct {
	Key     string        `help:"AMAP API key." env:"AMAP_API_KEY"`
	BaseUrl string        `help:"AMAP API base URL." env:"AMAP_BASE_URL" default:"https://restapi.amap.com"`
	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."`
}

type NearbyCmd

type NearbyCmd struct {
	Location  string  `help:"Center as 'longitude,latitude' or an address/place name (geocoded if not coordinates)." required:""`
	Keywords  string  `help:"Search keywords."`
	Types     string  `help:"POI type codes, pipe-separated."`
	Radius    int     `help:"Search radius in meters (0-50000)." default:"5000"`
	SortRule  string  `help:"Sort rule: distance or weight." default:"distance" enum:"distance,weight"`
	Limit     int     `help:"Number of POIs to return (max 20)."`
	MinCost   float64 `name:"min-cost" help:"Minimum per-person cost; excludes POIs without cost data."`
	MaxCost   float64 `name:"max-cost" help:"Maximum per-person cost; excludes POIs without cost data."`
	MinRating float64 `name:"min-rating" help:"Minimum rating 0-5; excludes POIs without rating data."`
}

func (*NearbyCmd) Run

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

type Root

type Root struct {
	Global     GlobalOptions `embed:""`
	Nearby     NearbyCmd     `cmd:"" help:"Search nearby places by location."`
	Search     SearchCmd     `cmd:"" help:"Search places by keyword or type."`
	Tips       TipsCmd       `cmd:"" help:"Query input suggestion tips by keyword."`
	Weather    WeatherCmd    `cmd:"" help:"Query live or forecast weather by city."`
	Directions DirectionsCmd `cmd:"" help:"Plan a route between origin and destination."`
}

Root defines the CLI command tree.

type SearchCmd

type SearchCmd struct {
	Keywords  string  `help:"Search keywords (required if --types is empty)."`
	Types     string  `help:"POI type codes, pipe-separated (required if --keywords is empty)."`
	Region    string  `help:"Region name, citycode, or adcode to bias search."`
	Limit     int     `help:"Number of POIs to return (max 20)."`
	MinCost   float64 `name:"min-cost" help:"Minimum per-person cost; excludes POIs without cost data."`
	MaxCost   float64 `name:"max-cost" help:"Maximum per-person cost; excludes POIs without cost data."`
	MinRating float64 `name:"min-rating" help:"Minimum rating 0-5; excludes POIs without rating data."`
}

func (*SearchCmd) Run

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

type TipsCmd

type TipsCmd struct {
	Keywords string `help:"Search keywords." required:""`
	Types    string `help:"POI type codes (or names), pipe-separated."`
	Location string `help:"Bias center as 'longitude,latitude' or an address (geocoded if not coordinates); only takes effect when --city is set."`
	City     string `help:"City name, citycode, or adcode to bias search."`
	DataType string `name:"datatype" help:"Data type filter: all, poi, bus, busline (pipe-separated)." default:"all"`
}

func (*TipsCmd) Run

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

type VersionFlag

type VersionFlag string

VersionFlag prints the version and exits.

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.

type WeatherCmd

type WeatherCmd struct {
	City       string `help:"City adcode (6 digits) or name; names are resolved via geocoding." required:""`
	Extensions string `help:"Weather type: base (live) or all (forecast)." default:"base" enum:"base,all"`
}

func (*WeatherCmd) Run

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

Jump to

Keyboard shortcuts

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