cli

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: MIT Imports: 18 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICLI

type ICLI interface {
	// The root directory from where certain operations are done,
	// i.e finding components etc.
	RootDir() string

	// RootCmd returns the root command on the CLI.
	RootCmd() *cobra.Command

	// RootArgs returns the root arguments for the CLI.
	RootArgs() *rootcmd.Args

	// Stages returns the set stage.
	Stages() stage.Stages

	// Config returns the overall customized config for the CLI.
	Config() config.IConfig

	// RunnerFactory gets the runner factory.
	RunnerFactory() factory.IFactory

	// toolchainDispatcher gets the toolchain dispatch function.
	ToolchainDispatcher() toolchain.IDispatcher

	// FindComponents returns components `comps` found by arguments `args` and
	// and all searched components `all` (needed to construct the DAG).
	FindComponents(args *general.ComponentArgs) (
		comps []*component.Component,
		all []*component.Component,
		rootDir string,
		err error,
	)

	// Run will run the CLI.
	Run() error
}

func New

func New(args *rootcmd.Args, config config.IConfig, opts ...Option) (ICLI, error)

New creates a new `quitsh` CLI application. The root arguments `args` generally point into the `config`. The CLI instance needs the full `config` because it will marshall/unmarshall it from disk by the `rootCmd`.

type Option

type Option func(c *cliApp) error

func WithCompFindOptions added in v0.24.0

func WithCompFindOptions(opts ...query.Option) Option

WithCompFindOptions adds component find options which will be added by default to the `FindComponents` command.

func WithConfigFilename

func WithConfigFilename(filename string) Option

WithConfigFilename sets the components config filename which is used to find components, default is `comp.ConfigFileName`.

func WithDescription

func WithDescription(desc string) Option

WithDescription setts the description on the CLI application.

func WithName

func WithName(name string) Option

WithName setts the name on the CLI application.

func WithStages

func WithStages(ss ...stage.Stage) Option

WithStageTypes sets the stage types you want to use over all the project. Each stage also comes with a priority, so you have to order them here accordingly how they would appear in execution order. This is used internally to guard wrong configuration and may be used for sorting targets into stage.

func WithTargetToStageMapper

func WithTargetToStageMapper(mapper stage.TargetNameToStageMapper) Option

WithTargetToStageMapper installs a custom target name to stage mapper. This is useful to not name the `stage` keyword in every target config.

func WithTargetToStageMapperDefault

func WithTargetToStageMapperDefault() Option

WithTargetToStageMapper installs a default target name to stage mapper. This is useful to not name the `stage` keyword in every target config.

  • If the target name contains a suffix equal to a stage name, this stage name will be default assigned (if not set).

func WithToolchainDispatcher

func WithToolchainDispatcher(dispatcher toolchain.IDispatcher) Option

WithToolchainDispatcher sets a toolchain dispatcher which is used to dispatches to the toolchain a runner specifies.

func WithToolchainDispatcherNix

func WithToolchainDispatcherNix(
	flakeDir string,
	argsSelector nixtoolchain.ArgsSelector,
) Option

WithToolchainDispatcherNix sets a toolchain dispatcher which will execute a runner by launching the following command inside a Nix development shell with name `toolchain`: ```shell

argsv[0] execute --running-in-toolchain --config temp.yaml

``` Where the parameters for `exec` are marshaled to `temp.yaml`. NOTE: When you use this option, you need to add the `execute` command with `exec.AddCmd` to the root command.

func WithVersion

func WithVersion(version *version.Version) Option

WithVersion setts the version on the CLI application.

Jump to

Keyboard shortcuts

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