cli

package
v3.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoArgsGiven = errors.New("no arguments given")

Functions

func MustRun

func MustRun(stdin io.Reader, stdout, stderr io.Writer)

func Run

func Run(stdin io.Reader, stdout, stderr io.Writer) (*kong.Context, error)

Types

type CLI

type CLI struct {
	Globals

	Query       QueryCmd       `cmd:"" default:"withargs" help:"[default] Execute a query"`
	Version     VersionCmd     `cmd:"" help:"Print the version"`
	Interactive InteractiveCmd `cmd:"" help:"Start an interactive session (alpha)"`
}

type Config

type Config struct {
	DefaultFormat string `yaml:"default_format"`
}

Config holds the contents of a config file.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads the config from the given path. If already loaded, returned previously loaded config.

type Globals

type Globals struct {
	Stdin  io.Reader `kong:"-"`
	Stdout io.Writer `kong:"-"`
	Stderr io.Writer `kong:"-"`
	// contains filtered or unexported fields
}

type InteractiveCmd

type InteractiveCmd struct {
	Vars              variables         `flag:"" name:"var" help:"Variables to pass to the query. E.g. --var foo=\"bar\" --var baz=json:file:./some/file.json"`
	ExtReadWriteFlags extReadWriteFlags `` /* 129-byte string literal not displayed */
	ExtReadFlags      extReadWriteFlags `flag:"" name:"read-flag" help:"Reader flag to customise parsing. E.g. --read-flag xml-mode=structured"`
	ExtWriteFlags     extReadWriteFlags `flag:"" name:"write-flag" help:"Writer flag to customise output. E.g. --write-flag csv-delimiter=;"`
	InFormat          string            `flag:"" name:"in" short:"i" help:"The format of the input data."`
	OutFormat         string            `flag:"" name:"out" short:"o" help:"The format of the output data."`

	ConfigPath string `name:"config" short:"c" help:"Path to config file" default:"~/dasel.yaml"`

	Query string `arg:"" help:"The query to execute." optional:"" default:""`
}

func NewInteractiveCmd

func NewInteractiveCmd(queryCmd *QueryCmd) *InteractiveCmd

func (*InteractiveCmd) Run

func (c *InteractiveCmd) Run(ctx *Globals) error

type QueryCmd

type QueryCmd struct {
	Vars              variables         `flag:"" name:"var" help:"Variables to pass to the query. E.g. --var foo=\"bar\" --var baz=json:file:./some/file.json"`
	ExtReadWriteFlags extReadWriteFlags `` /* 129-byte string literal not displayed */
	ExtReadFlags      extReadWriteFlags `flag:"" name:"read-flag" help:"Reader flag to customise parsing. E.g. --read-flag xml-mode=structured"`
	ExtWriteFlags     extReadWriteFlags `flag:"" name:"write-flag" help:"Writer flag to customise output. E.g. --write-flag csv-delimiter=;"`
	InFormat          string            `flag:"" name:"in" short:"i" help:"The format of the input data."`
	OutFormat         string            `flag:"" name:"out" short:"o" help:"The format of the output data."`
	ReturnRoot        bool              `flag:"" name:"root" help:"Return the root value."`
	Unstable          bool              `flag:"" name:"unstable" help:"Allow access to potentially unstable features."`
	Interactive       bool              `flag:"" name:"it" help:"Run in interactive mode (alpha)."`

	ConfigPath string `name:"config" short:"c" help:"Path to config file" default:"~/dasel.yaml"`

	Query string `arg:"" help:"The query to execute." optional:"" default:""`
}

func (*QueryCmd) Run

func (c *QueryCmd) Run(ctx *Globals) error

type VersionCmd

type VersionCmd struct {
}

func (*VersionCmd) Run

func (c *VersionCmd) Run(ctx *Globals) error

Jump to

Keyboard shortcuts

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