|
virtual std::string | description () |
|
virtual bool | forceImpureByDefault () |
|
virtual std::string | doc () |
|
virtual Path | getCommandBaseDir () const |
| Get the base directory for the command.
|
|
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 | expectArg (const std::string &label, std::filesystem::path *dest, bool optional=false) |
|
void | expectArgs (const std::string &label, std::vector< std::string > *dest) |
|
virtual nlohmann::json | toJSON () |
|
RootArgs & | getRoot () |
|
◆ CompleterClosure
The closure type of the completion callback.
This is what is actually stored as part of each Flag / Expected Arg.
◆ CompleterFun
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
◆ description()
virtual std::string nix::Args::description |
( |
| ) |
|
|
inlinevirtual |
Return a short one-line description of the command.
Reimplemented in CmdAdd, CmdAddDerivation, CmdAddFile, CmdAddPath, CmdBuild, CmdBundle, CmdCatNar, CmdCatStore, CmdConfig, CmdConfigCheck, CmdConfigShow, CmdCopy, CmdCopyLog, CmdCopySigs, CmdDerivation, CmdDevelop, CmdDiffClosures, CmdDumpPath2, CmdDumpPath, CmdEdit, CmdEnv, CmdEval, CmdFlake, CmdFlakeArchive, CmdFlakeCheck, CmdFlakeClone, CmdFlakeInit, CmdFlakeLock, CmdFlakeMetadata, CmdFlakeNew, CmdFlakePrefetch, CmdFlakeShow, CmdFlakeUpdate, CmdFmt, CmdHash, CmdHashBase, CmdHashConvert, CmdKey, CmdKeyConvertSecretToPublic, CmdKeyGenerateSecret, CmdLog, CmdLsNar, CmdLsStore, CmdMakeContentAddressed, CmdNar, CmdOptimiseStore, CmdPathFromHashPart, CmdPathInfo, CmdPingStore, CmdPrintDevEnv, CmdProfile, CmdProfileDiffClosures, CmdProfileHistory, CmdProfileInstall, CmdProfileList, CmdProfileRemove, CmdProfileRollback, CmdProfileUpgrade, CmdProfileWipeHistory, CmdRealisation, CmdRealisationInfo, CmdRegistry, CmdRegistryAdd, CmdRegistryList, CmdRegistryPin, CmdRegistryRemove, CmdRun, CmdSearch, CmdShell, CmdShowDerivation, CmdSign, CmdStore, CmdStoreDelete, CmdStoreGC, CmdStorePrefetchFile, CmdStoreRepair, CmdToBase, CmdUpgradeNix, CmdVerify, CmdWhyDepends, nix::CmdHelp, nix::CmdHelpStores, nix::CmdRepl, and nix::NixArgs.
◆ doc()
virtual std::string nix::Args::doc |
( |
| ) |
|
|
inlinevirtual |
Return documentation about this command, in Markdown format.
Reimplemented in CmdAdd, CmdAddDerivation, CmdBuild, CmdBundle, CmdCatNar, CmdCatStore, CmdCopy, CmdCopyLog, CmdDevelop, CmdDiffClosures, CmdDumpPath2, CmdDumpPath, CmdEdit, CmdEval, CmdFlake, CmdFlakeArchive, CmdFlakeCheck, CmdFlakeClone, CmdFlakeInit, CmdFlakeLock, CmdFlakeMetadata, CmdFlakeNew, CmdFlakePrefetch, CmdFlakeShow, CmdFlakeUpdate, CmdFmt, CmdHashConvert, CmdKeyConvertSecretToPublic, CmdKeyGenerateSecret, CmdLog, CmdLsNar, CmdLsStore, CmdMakeContentAddressed, CmdNar, CmdOptimiseStore, CmdPathFromHashPart, CmdPathInfo, CmdPingStore, CmdPrintDevEnv, CmdProfile, CmdProfileDiffClosures, CmdProfileHistory, CmdProfileInstall, CmdProfileList, CmdProfileRemove, CmdProfileRollback, CmdProfileUpgrade, CmdProfileWipeHistory, CmdRealisationInfo, CmdRegistry, CmdRegistryAdd, CmdRegistryList, CmdRegistryPin, CmdRegistryRemove, CmdRun, CmdSearch, CmdShell, CmdShowDerivation, CmdStoreDelete, CmdStoreGC, CmdStorePrefetchFile, CmdStoreRepair, CmdUpgradeNix, CmdVerify, CmdWhyDepends, nix::CmdHelp, nix::CmdHelpStores, nix::CmdRepl, and nix::NixArgs.
◆ expectArg() [1/2]
void nix::Args::expectArg |
( |
const std::string & | label, |
|
|
std::filesystem::path * | dest, |
|
|
bool | optional = false ) |
|
inline |
◆ expectArg() [2/2]
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.
◆ getCommandBaseDir()
Path nix::Args::getCommandBaseDir |
( |
| ) |
const |
|
virtual |
Get the base directory for the command.
- Returns
- Generally the working directory, but in case of a shebang interpreter, returns the directory of the script.
This only returns the correct value after parseCmdline() has run.
Reimplemented in nix::RootArgs.
◆ 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. |
Reimplemented in 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
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:
- /home/buildozer/aports/community/nix/src/nix-2.26.3/src/libutil/args.hh
- /home/buildozer/aports/community/nix/src/nix-2.26.3/src/libutil/args.cc