cli

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cli implements the goplaces command-line interface.

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, 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.

type AutocompleteCmd added in v0.2.0

type AutocompleteCmd struct {
	Input        string   `arg:"" name:"input" help:"Autocomplete input text."`
	Limit        int      `help:"Max suggestions (1-20)." default:"5"`
	SessionToken string   `help:"Session token for billing consistency."`
	Language     string   `help:"BCP-47 language code (e.g. en, en-US)."`
	Region       string   `help:"CLDR region code (e.g. US, DE)."`
	Lat          *float64 `help:"Latitude for location bias."`
	Lng          *float64 `help:"Longitude for location bias."`
	RadiusM      *float64 `help:"Radius in meters for location bias."`
}

AutocompleteCmd runs autocomplete queries.

func (*AutocompleteCmd) Run added in v0.2.0

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

Run executes the autocomplete command.

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 DetailsCmd

type DetailsCmd struct {
	PlaceID  string `arg:"" name:"place_id" help:"Place ID."`
	Language string `help:"BCP-47 language code (e.g. en, en-US)."`
	Region   string `help:"CLDR region code (e.g. US, DE)."`
	Reviews  bool   `help:"Include reviews in the response."`
	Photos   bool   `help:"Include photos in the response."`
}

DetailsCmd fetches place details.

func (*DetailsCmd) Run

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

Run executes the details command.

type DirectionsCmd added in v0.3.0

type DirectionsCmd struct {
	From          string   `help:"Origin address or place name."`
	To            string   `help:"Destination address or place name."`
	FromPlaceID   string   `help:"Origin place ID." name:"from-place-id"`
	ToPlaceID     string   `help:"Destination place ID." name:"to-place-id"`
	FromLat       *float64 `help:"Origin latitude." name:"from-lat"`
	FromLng       *float64 `help:"Origin longitude." name:"from-lng"`
	ToLat         *float64 `help:"Destination latitude." name:"to-lat"`
	ToLng         *float64 `help:"Destination longitude." name:"to-lng"`
	Mode          string   `help:"Travel mode: walk, drive, bicycle, transit." default:"walk"`
	Compare       string   `help:"Compare with another mode: walk, drive, bicycle, transit."`
	Steps         bool     `help:"Include step-by-step instructions."`
	Units         string   `help:"Units: metric or imperial." default:"metric"`
	AvoidTolls    bool     `help:"Avoid toll roads when driving."`
	AvoidHighways bool     `help:"Avoid highways when driving."`
	AvoidFerries  bool     `help:"Avoid ferries when driving."`
	Language      string   `help:"BCP-47 language code (e.g. en, en-US)."`
	Region        string   `help:"CLDR region code (e.g. US, DE)."`
}

DirectionsCmd fetches directions between two points.

func (*DirectionsCmd) Run added in v0.3.0

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

Run executes the directions command.

type GlobalOptions

type GlobalOptions struct {
	APIKey            string        `help:"Google Places API key." env:"GOOGLE_PLACES_API_KEY"`
	BaseURL           string        `help:"Places API base URL." env:"GOOGLE_PLACES_BASE_URL" default:"https://places.googleapis.com/v1"`
	RoutesBaseURL     string        `help:"Routes API base URL." env:"GOOGLE_ROUTES_BASE_URL" default:"https://routes.googleapis.com"`
	DirectionsBaseURL string        `help:"Directions Routes API base URL." env:"GOOGLE_DIRECTIONS_BASE_URL" default:"https://routes.googleapis.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."`
}

GlobalOptions are flags shared by all commands.

type NearbyCmd added in v0.2.0

type NearbyCmd struct {
	Limit       int      `help:"Max results (1-20)." default:"10"`
	Type        []string `help:"Included place types. Repeatable."`
	ExcludeType []string `help:"Excluded place types. Repeatable."`
	Language    string   `help:"BCP-47 language code (e.g. en, en-US)."`
	Region      string   `help:"CLDR region code (e.g. US, DE)."`
	Lat         *float64 `help:"Latitude for location restriction."`
	Lng         *float64 `help:"Longitude for location restriction."`
	RadiusM     *float64 `help:"Radius in meters for location restriction."`
}

NearbyCmd runs nearby searches.

func (*NearbyCmd) Run added in v0.2.0

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

Run executes the nearby command.

type PhotoCmd added in v0.2.0

type PhotoCmd struct {
	Name        string `arg:"" name:"photo_name" help:"Photo resource name (places/.../photos/...)."`
	MaxWidthPx  int    `help:"Max width in pixels." name:"max-width"`
	MaxHeightPx int    `help:"Max height in pixels." name:"max-height"`
}

PhotoCmd fetches a photo URL.

func (*PhotoCmd) Run added in v0.2.0

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

Run executes the photo command.

type ResolveCmd

type ResolveCmd struct {
	LocationText string `arg:"" name:"location" help:"Location text to resolve."`
	Limit        int    `help:"Max results (1-10)." default:"5"`
	Language     string `help:"BCP-47 language code (e.g. en, en-US)."`
	Region       string `help:"CLDR region code (e.g. US, DE)."`
}

ResolveCmd resolves a location string into candidates.

func (*ResolveCmd) Run

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

Run executes the resolve command.

type Root

type Root struct {
	Global       GlobalOptions   `embed:""`
	Autocomplete AutocompleteCmd `cmd:"" help:"Autocomplete places and queries."`
	Nearby       NearbyCmd       `cmd:"" help:"Search nearby places by location."`
	Search       SearchCmd       `cmd:"" help:"Search places by text query."`
	Route        RouteCmd        `cmd:"" help:"Search places along a route."`
	Directions   DirectionsCmd   `cmd:"" help:"Get directions and travel time between two points."`
	Details      DetailsCmd      `cmd:"" help:"Fetch place details by place ID."`
	Photo        PhotoCmd        `cmd:"" help:"Fetch a photo URL by photo name."`
	Resolve      ResolveCmd      `cmd:"" help:"Resolve a location string to candidate places."`
}

Root defines the CLI command tree.

type RouteCmd added in v0.2.0

type RouteCmd struct {
	Query        string  `arg:"" name:"query" help:"Search text."`
	From         string  `help:"Origin location (address or place name)."`
	To           string  `help:"Destination location (address or place name)."`
	Mode         string  `help:"Travel mode: DRIVE, WALK, BICYCLE, TWO_WHEELER, TRANSIT." default:"DRIVE"`
	RadiusM      float64 `help:"Search radius in meters." default:"1000"`
	MaxWaypoints int     `help:"Max sampled waypoints along the route." default:"5"`
	Limit        int     `help:"Max results per waypoint (1-20)." default:"5"`
	Language     string  `help:"BCP-47 language code (e.g. en, en-US)."`
	Region       string  `help:"CLDR region code (e.g. US, DE)."`
}

RouteCmd searches along a route between two locations.

func (*RouteCmd) Run added in v0.2.0

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

Run executes the route command.

type SearchCmd

type SearchCmd struct {
	Query      string   `arg:"" name:"query" help:"Search text."`
	Limit      int      `help:"Max results (1-20)." default:"10"`
	PageToken  string   `help:"Page token for pagination."`
	Language   string   `help:"BCP-47 language code (e.g. en, en-US)."`
	Region     string   `help:"CLDR region code (e.g. US, DE)."`
	Keyword    string   `help:"Keyword to append to the query."`
	Type       []string `help:"Place type filter (includedType). Repeatable."`
	OpenNow    *bool    `help:"Return only currently open places."`
	MinRating  *float64 `help:"Minimum rating (0-5)."`
	PriceLevel []int    `help:"Price levels 0-4. Repeatable."`
	Lat        *float64 `help:"Latitude for location bias."`
	Lng        *float64 `help:"Longitude for location bias."`
	RadiusM    *float64 `help:"Radius in meters for location bias."`
}

SearchCmd runs text search queries.

func (*SearchCmd) Run

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

Run executes the search command.

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.

Jump to

Keyboard shortcuts

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