Protocols
The following protocols are available globally.
-
Protocol that defines the help generation logic. This protocol has an extension that implements all the methods required. You can choose to override
helpMessage
to completely costumize the help message to print. Alternatively, override one of the sections only to alter that section.When the help is about to be printed, a
CommandHelp
is generated from the currentCommand
. aHelpGenerator
is created and passed thisCommandHelp
. theHelpGenerator
is used to print the help message string
The help has this format
See moreUsage: command [flags] command [command] Aliases: alias1, alias2 Examples: the command usage example Available Commands: sub_command1 subcommand description sub_command2 subcommand description Flags: -f, --flag flag1 description --user string flag2 description Use "command [command] --help" for more information about a command.
Declaration
Swift
public protocol HelpGenerator
-
Protocol that defines the needs to be implemented for a type to be used as a flag value
Example
Flag with User type
struct User: FlagValue { let name: String static func fromString(flagValue value: String) throws -> User { return User(name: value) } static var typeDescription: String { return "A user structure" } }
We can then use user to define flag type:
See morelet flag = try! Flag(longName: "debug", type: User.self)
Declaration
Swift
public protocol FlagValue