|
| virtual std::string | description () |
|
virtual bool | forceImpureByDefault () |
| virtual std::string | doc () |
|
virtual AsyncIoRoot & | aio ()=0 |
|
void | addFlag (Flag &&flag) |
|
void | removeFlag (const std::string &longName) |
|
void | expectArgs (ExpectedArg &&arg) |
| void | expectArg (const std::string &label, std::string *dest, bool optional=false) |
| void | expectArgs (const std::string &label, std::vector< std::string > *dest) |
|
virtual JSON | toJSON () |
| RootArgs & | getRoot () |
|
| MultiCommand * | parent = nullptr |
|
| virtual bool | processFlag (Strings::iterator &pos, Strings::iterator end) |
| virtual bool | processArgs (const Strings &args, bool finish) |
|
virtual Strings::iterator | rewriteArgs (Strings &args, Strings::iterator pos) |
| virtual void | initialFlagsProcessed () |
| virtual std::optional< std::reference_wrapper< RootArgs > > | asRootArgs () |
|
| static const size_t | ArityAny = std::numeric_limits<size_t>::max() |
◆ CompleterClosure
The closure type of the completion callback.
This is what is actually stored as part of each Flag / Expected Arg.
◆ CompleterFun
| typedef void nix::Args::CompleterFun(AddCompletions &, size_t, std::string_view) |
|
protected |
The basic function type of the completion callback.
Used to define CompleterClosure and some common case completers that individual flags/arguments can use.
The AddCompletions that is passed is an interface to the state stored as part of the root command
◆ asRootArgs()
| virtual std::optional< std::reference_wrapper< RootArgs > > nix::Args::asRootArgs |
( |
| ) |
|
|
inlineprotectedvirtual |
Returns this Args as a RootArgs if it is one, or std::nullopt otherwise.
◆ description()
| virtual std::string nix::Args::description |
( |
| ) |
|
|
inlinevirtual |
Return a short one-line description of the command.
Reimplemented in nix::CmdAddDerivation, nix::CmdAddFile, nix::CmdAddPath, nix::CmdBuild, nix::CmdBundle, nix::CmdCatNar, nix::CmdCatStore, nix::CmdConfig, nix::CmdConfigShow, nix::CmdCopy, nix::CmdCopyLog, nix::CmdCopySigs, nix::CmdDaemon, nix::CmdDerivation, nix::CmdDevelop, nix::CmdDiffClosures, nix::CmdDoctor, nix::CmdDumpPath2, nix::CmdDumpPath, nix::CmdEdit, nix::CmdEval, nix::CmdFlake, nix::CmdFlakeArchive, nix::CmdFlakeCheck, nix::CmdFlakeClone, nix::CmdFlakeInit, nix::CmdFlakeLock, nix::CmdFlakeMetadata, nix::CmdFlakeNew, nix::CmdFlakePrefetch, nix::CmdFlakeShow, nix::CmdFlakeUpdate, nix::CmdFmt, nix::CmdHash, nix::CmdHashBase, nix::CmdHelp, nix::CmdHelpStores, nix::CmdKey, nix::CmdKeyConvertSecretToPublic, nix::CmdKeyGenerateSecret, nix::CmdLog, nix::CmdLsNar, nix::CmdLsStore, nix::CmdMakeContentAddressed, nix::CmdNar, nix::CmdOptimiseStore, nix::CmdPathFromHashPart, nix::CmdPathInfo, nix::CmdPingStore, nix::CmdPrintDevEnv, nix::CmdProfile, nix::CmdProfileDiffClosures, nix::CmdProfileHistory, nix::CmdProfileInstall, nix::CmdProfileList, nix::CmdProfileRemove, nix::CmdProfileRollback, nix::CmdProfileUpgrade, nix::CmdProfileWipeHistory, nix::CmdRealisation, nix::CmdRealisationInfo, nix::CmdRegistry, nix::CmdRegistryAdd, nix::CmdRegistryList, nix::CmdRegistryPin, nix::CmdRegistryRemove, nix::CmdRepl, nix::CmdRun, nix::CmdSearch, nix::CmdShell, nix::CmdShowDerivation, nix::CmdSign, nix::CmdStore, nix::CmdStoreDelete, nix::CmdStoreGC, nix::CmdStorePrefetchFile, nix::CmdStoreRepair, nix::CmdToBase, nix::CmdUpgradeNix, nix::CmdVerify, nix::CmdWhyDepends, and nix::NixArgs.
◆ doc()
| virtual std::string nix::Args::doc |
( |
| ) |
|
|
inlinevirtual |
Return documentation about this command, in Markdown format.
Reimplemented in nix::CmdAddDerivation, nix::CmdAddFile, nix::CmdAddPath, nix::CmdBuild, nix::CmdBundle, nix::CmdCatNar, nix::CmdCatStore, nix::CmdCopy, nix::CmdCopyLog, nix::CmdDaemon, nix::CmdDevelop, nix::CmdDiffClosures, nix::CmdDumpPath2, nix::CmdDumpPath, nix::CmdEdit, nix::CmdEval, nix::CmdFlake, nix::CmdFlakeArchive, nix::CmdFlakeCheck, nix::CmdFlakeClone, nix::CmdFlakeInit, nix::CmdFlakeLock, nix::CmdFlakeMetadata, nix::CmdFlakeNew, nix::CmdFlakePrefetch, nix::CmdFlakeShow, nix::CmdFlakeUpdate, nix::CmdFmt, nix::CmdHelp, nix::CmdHelpStores, nix::CmdKeyConvertSecretToPublic, nix::CmdKeyGenerateSecret, nix::CmdLog, nix::CmdLsNar, nix::CmdLsStore, nix::CmdMakeContentAddressed, nix::CmdNar, nix::CmdOptimiseStore, nix::CmdPathFromHashPart, nix::CmdPathInfo, nix::CmdPingStore, nix::CmdPrintDevEnv, nix::CmdProfile, nix::CmdProfileDiffClosures, nix::CmdProfileHistory, nix::CmdProfileInstall, nix::CmdProfileList, nix::CmdProfileRemove, nix::CmdProfileRollback, nix::CmdProfileUpgrade, nix::CmdProfileWipeHistory, nix::CmdRealisationInfo, nix::CmdRegistry, nix::CmdRegistryAdd, nix::CmdRegistryList, nix::CmdRegistryPin, nix::CmdRegistryRemove, nix::CmdRepl, nix::CmdRun, nix::CmdSearch, nix::CmdShell, nix::CmdShowDerivation, nix::CmdStoreDelete, nix::CmdStoreGC, nix::CmdStorePrefetchFile, nix::CmdStoreRepair, nix::CmdUpgradeNix, nix::CmdVerify, nix::CmdWhyDepends, and nix::NixArgs.
◆ expectArg()
| void nix::Args::expectArg |
( |
const std::string & | label, |
|
|
std::string * | dest, |
|
|
bool | optional = false ) |
|
inline |
Expect a string argument.
◆ expectArgs()
| void nix::Args::expectArgs |
( |
const std::string & | label, |
|
|
std::vector< std::string > * | dest ) |
|
inline |
Expect 0 or more arguments.
◆ getRoot()
| RootArgs & nix::Args::getRoot |
( |
| ) |
|
Traverse parent pointers until we find the rootarguments object.
◆ initialFlagsProcessed()
| virtual void nix::Args::initialFlagsProcessed |
( |
| ) |
|
|
inlineprotectedvirtual |
Called after all command line flags before the first non-flag argument (if any) have been processed.
◆ processArgs()
| bool nix::Args::processArgs |
( |
const Strings & | args, |
|
|
bool | finish ) |
|
protectedvirtual |
Process some positional arugments
- Parameters
-
| finish | We have parsed everything else, and these are the only arguments left. Used because we accumulate some "pending args" we might have left over. |
- Returns
- true if the passed arguments were fully consumed and no further processing is required, false if the passed arguments should be processed with more context.
Reimplemented in nix::ExternalCommand, nix::LegacyArgs, and nix::MultiCommand.
◆ processFlag()
| bool nix::Args::processFlag |
( |
Strings::iterator & | pos, |
|
|
Strings::iterator | end ) |
|
protectedvirtual |
◆ ArityAny
| const size_t nix::Args::ArityAny = std::numeric_limits<size_t>::max() |
|
staticprotected |
The largest size_t is used to indicate the "any" arity, for handlers/flags/arguments that accept an arbitrary number of arguments.
◆ expectedArgs
Queue of expected positional argument forms.
Positional argument descriptions are inserted on the back.
As positional arguments are passed, these are popped from the front, until there are hopefully none left as all args that were expected in fact were passed.
◆ longFlags
| std::map<std::string, Flag::ptr> nix::Args::longFlags |
|
protected |
Index of all registered "long" flag descriptions (flags like --long).
◆ parent
| MultiCommand* nix::Args::parent = nullptr |
The parent command, used if this is a subcommand.
Invariant: An Args with a null parent must also be a RootArgs
- Todo
- this would probably be better in the CommandClass. getRoot() could be an abstract method that peels off at most one layer before recuring.
◆ processedArgs
List of processed positional argument forms.
All items removed from expectedArgs are added here. After all arguments were processed, this list should be exactly the same as expectedArgs was before.
This list is used to extend the lifetime of the argument forms. If this is not done, some closures that reference the command itself will segfault.
◆ shortFlags
| std::map<char, Flag::ptr> nix::Args::shortFlags |
|
protected |
Index of all registered "short" flag descriptions (flags like -s).
The documentation for this class was generated from the following files:
- lix/libutil/args.hh
- lix/libutil/args.cc