Documentation ¶
Index ¶
- Constants
- func CmdID(repo, pkg, group, name string) string
- func CmdReverseID(repo, pkg, group, name string) string
- type Command
- type CommandInfo
- type CommandManifest
- type DefaultCommand
- func (cmd *DefaultCommand) ArgsUsage() string
- func (cmd *DefaultCommand) Arguments() []string
- func (cmd *DefaultCommand) Category() string
- func (cmd *DefaultCommand) CheckFlags() bool
- func (cmd *DefaultCommand) DocFile() string
- func (cmd *DefaultCommand) DocLink() string
- func (cmd *DefaultCommand) Examples() []ExampleEntry
- func (cmd *DefaultCommand) ExclusiveFlags() [][]string
- func (cmd *DefaultCommand) Executable() string
- func (cmd *DefaultCommand) Execute(envVars []string, args ...string) (int, error)
- func (cmd *DefaultCommand) ExecuteFlagValuesCmd(envVars []string, flagCmd []string, args ...string) (int, string, error)
- func (cmd *DefaultCommand) ExecuteValidArgsCmd(envVars []string, args ...string) (int, string, error)
- func (cmd *DefaultCommand) ExecuteWithOutput(envVars []string, args ...string) (int, string, error)
- func (cmd *DefaultCommand) FlagValuesCmd() []string
- func (cmd *DefaultCommand) Flags() []Flag
- func (cmd *DefaultCommand) FullGroup() string
- func (cmd *DefaultCommand) FullName() string
- func (cmd *DefaultCommand) Group() string
- func (cmd *DefaultCommand) GroupFlags() [][]string
- func (cmd *DefaultCommand) ID() string
- func (cmd *DefaultCommand) LongDescription() string
- func (cmd *DefaultCommand) Name() string
- func (cmd *DefaultCommand) PackageDir() string
- func (cmd *DefaultCommand) PackageName() string
- func (cmd *DefaultCommand) RepositoryID() string
- func (cmd *DefaultCommand) RequestedResources() []string
- func (cmd *DefaultCommand) RequiredFlags() []string
- func (cmd *DefaultCommand) RuntimeGroup() string
- func (cmd *DefaultCommand) RuntimeName() string
- func (cmd *DefaultCommand) SetNamespace(repoId string, pkgName string)
- func (cmd *DefaultCommand) SetPackageDir(pkgDir string)
- func (cmd *DefaultCommand) SetRuntimeGroup(name string)
- func (cmd *DefaultCommand) SetRuntimeName(name string)
- func (cmd *DefaultCommand) ShortDescription() string
- func (cmd *DefaultCommand) Type() string
- func (cmd *DefaultCommand) ValidArgs() []string
- func (cmd *DefaultCommand) ValidArgsCmd() []string
- type ExampleEntry
- type Flag
- type Package
- type PackageManifest
- type TemplateContext
Constants ¶
const ( CACHE_DIR_PATTERN = "#CACHE#" OS_PATTERN = "#OS#" ARCH_PATTERN = "#ARCH#" BINARY_PATTERN = "#BINARY#" SCRIPT_PATTERN = "#SCRIPT#" EXT_PATTERN = "#EXT#" SCRIPT_EXT_PATTERN = "#SCRIPT_EXT#" )
Variables ¶
This section is empty.
Functions ¶
func CmdReverseID ¶
Types ¶
type Command ¶
type Command interface { CommandManifest // the id of the reigstry that the command belongs to RepositoryID() string // the package name that the command belongs to PackageName() string // the full ID of the command: registry:package:group:name ID() string // the full group name: registry:package:group FullGroup() string // the full command name: registry:package:group:name FullName() string // the runtime group of the command RuntimeGroup() string // the runtime name of the command RuntimeName() string // the package directory PackageDir() string Execute(envVars []string, args ...string) (int, error) ExecuteWithOutput(envVars []string, args ...string) (int, string, error) ExecuteValidArgsCmd(envVars []string, args ...string) (int, string, error) ExecuteFlagValuesCmd(envVars []string, flagCmd []string, args ...string) (int, string, error) // namespace speficies the package and the registry/repository of the command // there could be two commands with the same group and name in different namespace // when resolving the group and name conflict, namespace is used to identify the // command SetNamespace(regId string, pkgName string) SetPackageDir(pkgDir string) SetRuntimeGroup(alias string) SetRuntimeName(alias string) }
type CommandInfo ¶
type CommandManifest ¶
type CommandManifest interface { CommandInfo Executable() string Arguments() []string ValidArgs() []string ValidArgsCmd() []string // deprecated in 1.9.0, replaced by Flags() RequiredFlags() []string Flags() []Flag ExclusiveFlags() [][]string GroupFlags() [][]string FlagValuesCmd() []string CheckFlags() bool }
type DefaultCommand ¶
type DefaultCommand struct { CmdID string CmdPackageName string CmdRepositoryID string CmdRuntimeGroup string CmdRuntimeName string CmdName string `json:"name" yaml:"name"` CmdCategory string `json:"category" yaml:"category"` CmdType string `json:"type" yaml:"type"` CmdGroup string `json:"group" yaml:"group"` CmdArgsUsage string `json:"argsUsage" yaml:"argsUsage"` // optional, set this field will custom the one line usage CmdExamples []ExampleEntry `json:"examples" yaml:"examples"` CmdShortDescription string `json:"short" yaml:"short"` CmdLongDescription string `json:"long" yaml:"long"` CmdExecutable string `json:"executable" yaml:"executable"` CmdArguments []string `json:"args" yaml:"args"` CmdDocFile string `json:"docFile" yaml:"docFile"` CmdDocLink string `json:"docLink" yaml:"docLink"` CmdValidArgs []string `json:"validArgs" yaml:"validArgs"` // the valid argument options CmdValidArgsCmd []string `json:"validArgsCmd" yaml:"validArgsCmd"` // the command to call to get the args for autocompletion CmdRequiredFlags []string `json:"requiredFlags" yaml:"requiredFlags"` // the required flags -- deprecated in 1.9.0, see flags, exclusiveFlags, and groupFlags CmdFlags []Flag `json:"flags" yaml:"flags"` CmdExclusiveFlags [][]string `json:"exclusiveFlags" yaml:"exclusiveFlags"` CmdGroupFlags [][]string `json:"groupFlags" yaml:"groupFlags"` CmdFlagValuesCmd []string `json:"flagValuesCmd" yaml:"flagValuesCmd"` // the command to call flag values for autocompletion CmdCheckFlags bool `json:"checkFlags" yaml:"checkFlags"` // whether parse the flags and check them before execution CmdRequestedResources []string `json:"requestedResources" yaml:"requestedResources"` PkgDir string `json:"pkgDir"` }
DefaultCommand implements the command.Command interface
There are two types of cdt command: 1. group command 2. executable command
A group command doesn't do any thing but contain other executable commands. An executable command must be under a group command, the default one is the cdt root (group = "")
for example, command: cdt hotfix create
hotfix is a group command, and create is a command under the "hotfix" group command
Another example: cdt ls, here ls is an executable command under the root "" group command
Note: nested group command is not supported! It is not a good practice to have to much level of nested commands like: cdt workspace create moab.
The group field of group command is ignored.
An additional "category" field is reserved in case we have too much first level commands, we can use it to category them in the cdt help output.
func NewDefaultCommandFromCopy ¶
func NewDefaultCommandFromCopy(cmd Command, pkgDir string) *DefaultCommand
func (*DefaultCommand) ArgsUsage ¶
func (cmd *DefaultCommand) ArgsUsage() string
custom the usage message for the arguments format this is useful to name your arguments and show argument orders this will replace the one-line usage message in help NOTE: there is no need to provide the command name in the usage it will be added by command launcher automatically
func (*DefaultCommand) Arguments ¶
func (cmd *DefaultCommand) Arguments() []string
func (*DefaultCommand) Category ¶
func (cmd *DefaultCommand) Category() string
func (*DefaultCommand) CheckFlags ¶
func (cmd *DefaultCommand) CheckFlags() bool
func (*DefaultCommand) DocFile ¶
func (cmd *DefaultCommand) DocFile() string
func (*DefaultCommand) DocLink ¶
func (cmd *DefaultCommand) DocLink() string
func (*DefaultCommand) Examples ¶
func (cmd *DefaultCommand) Examples() []ExampleEntry
func (*DefaultCommand) ExclusiveFlags ¶
func (cmd *DefaultCommand) ExclusiveFlags() [][]string
func (*DefaultCommand) Executable ¶
func (cmd *DefaultCommand) Executable() string
func (*DefaultCommand) Execute ¶
func (cmd *DefaultCommand) Execute(envVars []string, args ...string) (int, error)
func (*DefaultCommand) ExecuteFlagValuesCmd ¶
func (*DefaultCommand) ExecuteValidArgsCmd ¶
func (*DefaultCommand) ExecuteWithOutput ¶
func (*DefaultCommand) FlagValuesCmd ¶
func (cmd *DefaultCommand) FlagValuesCmd() []string
func (*DefaultCommand) Flags ¶
func (cmd *DefaultCommand) Flags() []Flag
func (*DefaultCommand) FullGroup ¶
func (cmd *DefaultCommand) FullGroup() string
Full group name in form of group name @ [empty] @ package @ repo Read as a group command named [name] in root group (empty) from package [package] managed by repo [repo]
func (*DefaultCommand) FullName ¶
func (cmd *DefaultCommand) FullName() string
Full command name in form of name @ group @ package @ repo Read as a command named [name] in group [group] from package [package] managed by repo [repo]
func (*DefaultCommand) Group ¶
func (cmd *DefaultCommand) Group() string
func (*DefaultCommand) GroupFlags ¶
func (cmd *DefaultCommand) GroupFlags() [][]string
func (*DefaultCommand) ID ¶
func (cmd *DefaultCommand) ID() string
func (*DefaultCommand) LongDescription ¶
func (cmd *DefaultCommand) LongDescription() string
func (*DefaultCommand) Name ¶
func (cmd *DefaultCommand) Name() string
func (*DefaultCommand) PackageDir ¶
func (cmd *DefaultCommand) PackageDir() string
func (*DefaultCommand) PackageName ¶
func (cmd *DefaultCommand) PackageName() string
func (*DefaultCommand) RepositoryID ¶
func (cmd *DefaultCommand) RepositoryID() string
func (*DefaultCommand) RequestedResources ¶
func (cmd *DefaultCommand) RequestedResources() []string
func (*DefaultCommand) RequiredFlags ¶
func (cmd *DefaultCommand) RequiredFlags() []string
func (*DefaultCommand) RuntimeGroup ¶
func (cmd *DefaultCommand) RuntimeGroup() string
func (*DefaultCommand) RuntimeName ¶
func (cmd *DefaultCommand) RuntimeName() string
func (*DefaultCommand) SetNamespace ¶
func (cmd *DefaultCommand) SetNamespace(repoId string, pkgName string)
func (*DefaultCommand) SetPackageDir ¶
func (cmd *DefaultCommand) SetPackageDir(pkgDir string)
func (*DefaultCommand) SetRuntimeGroup ¶
func (cmd *DefaultCommand) SetRuntimeGroup(name string)
func (*DefaultCommand) SetRuntimeName ¶
func (cmd *DefaultCommand) SetRuntimeName(name string)
func (*DefaultCommand) ShortDescription ¶
func (cmd *DefaultCommand) ShortDescription() string
func (*DefaultCommand) Type ¶
func (cmd *DefaultCommand) Type() string
func (*DefaultCommand) ValidArgs ¶
func (cmd *DefaultCommand) ValidArgs() []string
func (*DefaultCommand) ValidArgsCmd ¶
func (cmd *DefaultCommand) ValidArgsCmd() []string
type ExampleEntry ¶
type ExampleEntry struct { Scenario string `json:"scenario" yaml:"scenario"` Command string `json:"cmd" yaml:"cmd"` }
func (ExampleEntry) Clone ¶
func (example ExampleEntry) Clone() ExampleEntry
type Flag ¶
type Flag struct { FlagName string `json:"name" yaml:"name"` FlagType string `json:"type" yaml:"type"` FlagShortName string `json:"short" yaml:"short"` FlagDescription string `json:"desc" yaml:"desc"` FlagDefault string `json:"default" yaml:"default"` FlagRequired bool `json:"required" yaml:"required"` FlagValues []string `json:"values" yaml:"values"` FlagValuesCmd []string `json:"valuesCmd" yaml:"valuesCmd"` }
func (Flag) Description ¶
type Package ¶
type Package interface { PackageManifest // repository ID: dropin, default, repo1, repo2, ... RepositoryID() string // verify the sha256 checksum VerifyChecksum(checksum string) (bool, error) // verify the package signature VerifySignature(signature string) (bool, error) // install package to a local repository InstallTo(pathname string) (PackageManifest, error) // run setup process of the package RunSetup(pkgDir string) error }