Documentation
¶
Overview ¶
Package command implements the YAP CLI commands including build, install, graph, and utility operations.
Index ¶
- Variables
- func ContainerRuntimeOverride() string
- func CustomErrorHandler(cmd *cobra.Command, err error) error
- func CustomUsageFunc(cmd *cobra.Command) error
- func EnhancedHelpFunc(cmd *cobra.Command, _ []string)
- func Execute()
- func InitializeBuildDescriptions()
- func InitializeGensumDescriptions()
- func InitializeGraphDescriptions()
- func InitializeInstallDescriptions()
- func InitializeListDistrosDescriptions()
- func InitializeLocalizedDescriptions()
- func InitializePrepareDescriptions()
- func InitializeZapDescriptions()
- func IsInsideContainer() bool
- func IsNoColorEnabled() bool
- func ListDistros()
- func ParseFlexibleArgs(args []string) (distro, release, fullJSONPath string, err error)
- func ParseLanguageFlag()
- func PreRunValidation(cmd *cobra.Command, _ []string)
- func ProjectPathCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func ResolveDistroRelease(distro, release, noDistroKey string) (resolvedDistro, resolvedRelease string)
- func ResolveFlexibleDistro(args []string, noDistroKey string) (distro, release, fullJSONPath string, userProvided bool, err error)
- func RunCommandInContainer(distro, workDir string, subArgs []string) bool
- func RunPipelineInContainer(distro, workDir string, buildArgs, prepareArgs []string, skipPrepare bool) bool
- func SetupEnhancedHelp()
- func ShowCommandTips(cmd *cobra.Command)
- func ShowWelcomeMessage()
- func SmartErrorHandler(cmd *cobra.Command, err error) error
- func ValidDistrosCompletion(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
Constants ¶
This section is empty.
Variables ¶
var ( // GoLang indicates whether to prepare Go language environment. GoLang bool // TargetArch specifies the target architecture for cross-compilation. TargetArch string )
var ( ErrDistributionEmpty = errors.New(i18n.T("errors.validation.distribution_empty")) ErrProjectPathEmpty = errors.New(i18n.T("errors.validation.project_path_empty")) ErrPathNotExist = errors.New(i18n.T("errors.validation.path_not_exist")) ErrProjectFileNotFound = errors.New(i18n.T("errors.validation.project_file_not_found")) ErrInsufficientArgs = errors.New(i18n.T("errors.validation.insufficient_args")) )
Static error definitions to satisfy err113 linter.
Functions ¶
func ContainerRuntimeOverride ¶ added in v2.1.0
func ContainerRuntimeOverride() string
ContainerRuntimeOverride returns the value of the --runtime flag. Empty string means auto-detect.
func CustomErrorHandler ¶
CustomErrorHandler provides enhanced error messages with styling.
func CustomUsageFunc ¶
CustomUsageFunc provides enhanced usage information with organized flag groups.
func EnhancedHelpFunc ¶
EnhancedHelpFunc provides a completely custom help function.
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func InitializeBuildDescriptions ¶
func InitializeBuildDescriptions()
InitializeBuildDescriptions sets the localized descriptions for the build command. This must be called after i18n is initialized.
func InitializeGensumDescriptions ¶
func InitializeGensumDescriptions()
InitializeGensumDescriptions sets the localized descriptions for gensum.
func InitializeGraphDescriptions ¶
func InitializeGraphDescriptions()
InitializeGraphDescriptions sets the localized descriptions for the graph command. This must be called after i18n is initialized.
func InitializeInstallDescriptions ¶
func InitializeInstallDescriptions()
InitializeInstallDescriptions sets the localized descriptions for the install command. This must be called after i18n is initialized.
func InitializeListDistrosDescriptions ¶
func InitializeListDistrosDescriptions()
InitializeListDistrosDescriptions sets the localized descriptions for the list-distros command. This must be called after i18n is initialized.
func InitializeLocalizedDescriptions ¶
func InitializeLocalizedDescriptions()
InitializeLocalizedDescriptions sets all localized command descriptions. This should be called from main() after ParseLanguageFlag() and after all commands are registered.
func InitializePrepareDescriptions ¶
func InitializePrepareDescriptions()
InitializePrepareDescriptions sets the localized descriptions for the prepare command. This must be called after i18n is initialized.
func InitializeZapDescriptions ¶
func InitializeZapDescriptions()
InitializeZapDescriptions sets the localized descriptions for the zap command. This must be called after i18n is initialized.
func IsInsideContainer ¶ added in v2.1.0
func IsInsideContainer() bool
IsInsideContainer returns true when the process is already running inside a YAP builder container or rootless namespace, or inside any OCI/Docker container environment (detected via standard indicators).
func IsNoColorEnabled ¶
func IsNoColorEnabled() bool
IsNoColorEnabled returns true if the --no-color flag was set.
func ParseFlexibleArgs ¶
ParseFlexibleArgs parses flexible command arguments for build and zap commands that support both "command path" and "command distro path" formats. Returns (distro, release, fullJSONPath, error).
func ParseLanguageFlag ¶
func ParseLanguageFlag()
ParseLanguageFlag scans os.Args for -l / --language before cobra parses flags, so that i18n is re-initialised with the correct locale before InitializeLocalizedDescriptions() sets all command descriptions — including the path taken by --help, which never fires PersistentPreRun.
func PreRunValidation ¶
PreRunValidation provides pre-run validation with interactive prompts for missing arguments.
func ProjectPathCompletion ¶
func ProjectPathCompletion(_ *cobra.Command, _ []string, _ string) ( []string, cobra.ShellCompDirective)
ProjectPathCompletion provides completion for project paths (directories with yap.json or PKGBUILD).
func ResolveDistroRelease ¶
func ResolveDistroRelease(distro, release, noDistroKey string) ( resolvedDistro, resolvedRelease string, )
ResolveDistroRelease auto-detects the distribution and codename from /etc/os-release when not explicitly provided.
Behavior:
- If distro is empty: the host distro and codename are used; a warning is logged using noDistroKey (an i18n key for "no distribution specified").
- If distro is set but release is empty: the value is treated as an explicitly-requested bare distro family (generic). The codename is NOT back-filled from the host, so format-specific suffixes fall back to the distro name (e.g. a deb release stays `1ubuntu` instead of `1jammy`).
This keeps `build`, `zap`, and `prepare` consistent: host-codename auto-detection only kicks in when no distro argument was provided.
func ResolveFlexibleDistro ¶ added in v2.3.3
func ResolveFlexibleDistro(args []string, noDistroKey string) ( distro, release, fullJSONPath string, userProvided bool, err error, )
ResolveFlexibleDistro parses "distro[-release] path" style arguments (via ParseFlexibleArgs) and auto-detects the distro/release from /etc/os-release when missing (via ResolveDistroRelease). userProvided reports whether the caller explicitly named a distro — used by `build` and `zap` to decide on container dispatch and logging.
func RunCommandInContainer ¶ added in v2.1.0
RunCommandInContainer re-invokes the given yap sub-command inside the appropriate distro container using the configured runtime.
- distro: distribution tag, e.g. "ubuntu-noble"
- workDir: host directory to mount as /project (must be absolute)
- subArgs: the yap sub-command + arguments to run inside, e.g. ["build", "ubuntu-noble", "/workspace/mypkg"]
Returns true if the command was dispatched (caller should return immediately), false if the caller should proceed natively (already inside a container, or runtime detection failed non-fatally).
func RunPipelineInContainer ¶ added in v2.1.0
func RunPipelineInContainer(distro, workDir string, buildArgs, prepareArgs []string, skipPrepare bool) bool
RunPipelineInContainer runs prepare then build in a single container invocation using a shell chain. This ensures makedeps installed by prepare are available to build without requiring a persistent container.
- distro: distribution tag, e.g. "ubuntu-noble"
- workDir: host directory to mount as /project
- buildArgs: arguments for the inner yap build command (distroTag + path plus any forwarded build flags such as --repo, -U, --target-arch)
- prepareArgs: extra flags to forward to the chained `yap prepare` step (e.g. --repo, --target-arch) so the prepare environment matches the build — repos added on the build side are not visible to prepare unless forwarded here
- skipPrepare: if true, skip the prepare step (user passed -s or -d)
Returns true if dispatched, false if caller should proceed natively.
func SetupEnhancedHelp ¶
func SetupEnhancedHelp()
SetupEnhancedHelp configures enhanced help formatting for commands.
func ShowCommandTips ¶
ShowCommandTips shows helpful tips based on command usage.
func ShowWelcomeMessage ¶
func ShowWelcomeMessage()
ShowWelcomeMessage displays a welcome message for first-time users.
func SmartErrorHandler ¶
SmartErrorHandler provides enhanced error messages with intelligent suggestions.
func ValidDistrosCompletion ¶
func ValidDistrosCompletion(_ *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective)
ValidDistrosCompletion provides completion for valid distributions.
Types ¶
This section is empty.