args

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	// All lists of all arguments in command line (not including the command itself)
	All []string
	// Completed lists of all completed arguments in command line,
	// If the last one is still being typed - no space after it,
	// it won't appear in this list of arguments.
	Completed []string
	// Last argument in command line, the one being typed, if the last
	// character in the command line is a space, this argument will be empty,
	// otherwise this would be the last word.
	Last string
	// LastCompleted is the last argument that was fully typed.
	// If the last character in the command line is space, this would be the
	// last word, otherwise, it would be the word before that.
	LastCompleted string

	// ParsedRoot is the return value of [Parser.Parse], and should be the root command
	// structure for your CLI framework.
	//
	// It's useful for a more complex, dynamic [Predictor]. For example, returning
	// different options depending on another flag value or positional argument.
	//
	// Always 'nil' when no Parser is provided.
	ParsedRoot any
}

Args describes command line arguments

func New

func New(line string, parser Parser) Args

func (Args) Directory

func (a Args) Directory() string

Directory gives the directory of the current written last argument if it represents a file name being written. in case that it is not, we fall back to the current directory.

Deprecated.

func (Args) From

func (a Args) From(i int) Args

From returns a copy of Args of all arguments after the i'th argument.

type Parser

type Parser interface {
	Parse(args []string) any
}

Parser accepts all completed arguments from the command-line and returns a domain-specific object representing the root command

Predictors may use this to gain insight into what else has been provided at any layer.

Jump to

Keyboard shortcuts

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