rootcmd

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 14 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 any) (rootCmd *cobra.Command, preExecFunc func() error)

Create a new `quitsh` root command with settings `setts` and root arguments `rootArgs`. The full argument structure `allArgs` is treated as `any` and will be used to parse the configuration files `--config` (`--config-user`) into before startup.

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:

  • Cobra sets defaults valutes in command definitions (unimportant).
  • The `preExecFunc`: We pass the config (hopefully defaulted), load potentially from `--config`, `--config-user` and `--config-values`.
  • 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.
	Config string `yaml:"-"`
	// The config YAML (user overlay).
	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"`

	// 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.
	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).

type Settings

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

Jump to

Keyboard shortcuts

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