Documentation
¶
Overview ¶
Package command implements the YAP CLI commands including build, install, graph, and utility operations.
Index ¶
- Variables
- 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 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 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 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 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 codename is auto-detected only when the host distro matches; a debug log is emitted on success.
This keeps `build`, `zap`, and `prepare` consistent so distro+codename PKGBUILD directives (e.g. depends__ubuntu_jammy) resolve correctly.
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.