rootcmd

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(setts *Settings, rootArgs *Args, config config.IConfig) (
	rootCmd *cobra.Command)

New creates a new `quitsh` root command with settings `setts` and root arguments `rootArgs`. The full argument structure `config` is treated as `any` and will be used to parse the configuration files `--config` (`--config-user`) into before startup. Note: The user must default `config` with `defaults.Set`. WARNING: The default values here set and in any subcommand, are unimportant! We load the config (the ground truth) always afterwards and before any arguments are parsed. The sequence is as follows:

  • Incoming `config` is defaulted from `defaults.Setter`.
  • Unmarshal from from `--config`, `--config-user` and `--config-values`.
  • Cobra sets defaults values in command definitions: -> IMPORTANT: default values must be to the same pointers when config pointer are used, cause otherwise it will overwrite with another default value!
  • Cobra executes and sets CLI arguments to override stuff as a final step.

Types

type Args

type Args struct {
	// The config YAML from which we read parameters for the CLI.
	// Preset by env. var `QUITSH_CONFIG`.
	Config string `yaml:"-"`
	// The config YAML (user overlay).
	// Preset by env. var `QUITSH_CONFIG_USER`.
	ConfigUser string `yaml:"-"`
	// Config key,value arguments to override nested config
	// values by paths e.g. `a.b.c: {"a":3}` on the command line.
	ConfigKeyValues []string `yaml:"-"`

	// Working directory to switch to at startup.
	// This will be used to search for components.
	// This will be used to define the `RootDir` directory.
	Cwd string `yaml:"cwd"`

	// The root directory of quitsh.
	// By default its the Git root directory resolved starting from
	// `Cwd`.
	RootDir string `yaml:"rootDir"`

	// The log level `debug,info,warning,error`.
	LogLevel string `yaml:"logLevel" default:""`

	// Enable environment print on command execution errors.
	EnableEnvPrint bool `yaml:"enableEnvPrint"`

	// Disable any toolchain dispatch which might happen.
	SkipToolchainDispatch bool `yaml:"skipToolchainDispatch"`

	// If we use a global output directory
	// instead of component's specific one.
	GlobalOutput bool `yaml:"globalOutput"`
	// Use a specific output directory (relative to root dir).
	GlobalOutputDir string `yaml:"outputDir"`

	// Enable running targets in parallel.
	Parallel bool `yaml:"parallel"`
}

Root arguments. NOTE: All fields need proper default values (here mostly empty).

func (*Args) SetDefaults added in v0.38.0

func (s *Args) SetDefaults()

SetDefaults implements defaults.Setter.

type Settings

type Settings struct {
	Name        string
	Version     *version.Version
	Description string
}

Root arguments. NOTE: All fields need proper default values (here mostly empty).

func (*Settings) SetDefaults added in v0.38.0

func (s *Settings) SetDefaults()

SetDefaults implements defaults.Setter.

Jump to

Keyboard shortcuts

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