![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
Classes | |
| struct | Handler |
| struct | Flag |
| struct | ExpectedArg |
Public Member Functions | |
| virtual std::string | description () |
| virtual bool | forceImpureByDefault () |
| virtual std::string | doc () |
| virtual std::filesystem::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 () |
Public Attributes | |
| MultiCommand * | parent = nullptr |
Static Public Attributes | |
| static CompleterFun | completePath |
| static CompleterFun | completeDir |
Protected Types | |
| using | CompleterFun = void(AddCompletions &, size_t, std::string_view) |
| using | CompleterClosure = std::function<CompleterFun> |
Protected Member Functions | |
| 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 | checkArgs () |
| virtual void | initialFlagsProcessed () |
Protected Attributes | |
| std::map< std::string, Flag::ptr > | longFlags |
| std::map< char, Flag::ptr > | shortFlags |
| std::list< ExpectedArg > | expectedArgs |
| std::list< ExpectedArg > | processedArgs |
| StringSet | hiddenCategories |
Static Protected Attributes | |
| static const size_t | ArityAny = std::numeric_limits<size_t>::max() |
Friends | |
| class | MultiCommand |
|
protected |
The closure type of the completion callback.
This is what is actually stored as part of each Flag / Expected Arg.
|
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
|
inlinevirtual |
Return a short one-line description of the command.
Reimplemented in nix::CmdAdd, nix::CmdAddDerivation, nix::CmdAddFile, nix::CmdAddPath, nix::CmdBuild, nix::CmdBuildTrace, nix::CmdBuildTraceDelete, nix::CmdBuildTraceInfo, nix::CmdBundle, nix::CmdCatNar, nix::CmdCatStore, nix::CmdConfig, nix::CmdConfigCheck, nix::CmdConfigShow, nix::CmdCopy, nix::CmdCopyLog, nix::CmdCopySigs, nix::CmdDaemon, nix::CmdDerivation, nix::CmdDevelop, nix::CmdDiffClosures, nix::CmdDumpPath2, nix::CmdDumpPath, nix::CmdEdit, nix::CmdEnv, nix::CmdEval, nix::CmdFlake, nix::CmdFlakeArchive, nix::CmdFlakeCheck, nix::CmdFlakeClone, nix::CmdFlakeInit, nix::CmdFlakeLock, nix::CmdFlakeMetadata, nix::CmdFlakeNew, nix::CmdFlakePrefetch, nix::CmdFlakePrefetchInputs, nix::CmdFlakeShow, nix::CmdFlakeUpdate, nix::CmdFormatter, nix::CmdFormatterBuild, nix::CmdFormatterRun, nix::CmdHash, nix::CmdHashBase, nix::CmdHashConvert, nix::CmdHelp, nix::CmdHelpStores, nix::CmdInfoStore, nix::CmdKey, nix::CmdKeyConvertSecretToPublic, nix::CmdKeyGenerateSecret, nix::CmdLog, nix::CmdLsNar, nix::CmdLsStore, nix::CmdMakeContentAddressed, nix::CmdNar, nix::CmdOptimiseStore, nix::CmdPathFromHashPart, nix::CmdPathInfo, nix::CmdPrintDevEnv, nix::CmdProfile, nix::CmdProfileAdd, nix::CmdProfileDiffClosures, nix::CmdProfileHistory, nix::CmdProfileList, nix::CmdProfileRemove, nix::CmdProfileRollback, nix::CmdProfileUpgrade, nix::CmdProfileWipeHistory, nix::CmdRegistry, nix::CmdRegistryAdd, nix::CmdRegistryList, nix::CmdRegistryPin, nix::CmdRegistryRemove, nix::CmdRegistryResolve, nix::CmdRepl, nix::CmdRootsDaemon, nix::CmdRun, nix::CmdSearch, nix::CmdShell, nix::CmdShowDerivation, nix::CmdSign, nix::CmdStore, nix::CmdStoreDelete, nix::CmdStoreGC, nix::CmdStorePrefetchFile, nix::CmdStoreRepair, nix::CmdSubmitOutput, nix::CmdToBase, nix::CmdUpgradeNix, nix::CmdVerify, nix::CmdVersion, nix::CmdWhyDepends, and nix::NixArgs.
|
inlinevirtual |
Return documentation about this command, in Markdown format.
Reimplemented in nix::CmdAdd, nix::CmdAddDerivation, nix::CmdBuild, nix::CmdBuildTraceDelete, nix::CmdBuildTraceInfo, nix::CmdBundle, nix::CmdCatNar, nix::CmdCatStore, nix::CmdCopy, nix::CmdCopyLog, nix::CmdCopySigs, 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::CmdFlakePrefetchInputs, nix::CmdFlakeShow, nix::CmdFlakeUpdate, nix::CmdFormatterBuild, nix::CmdFormatterRun, nix::CmdHashConvert, nix::CmdHelp, nix::CmdHelpStores, nix::CmdInfoStore, nix::CmdKeyConvertSecretToPublic, nix::CmdKeyGenerateSecret, nix::CmdLog, nix::CmdLsNar, nix::CmdLsStore, nix::CmdMakeContentAddressed, nix::CmdNar, nix::CmdOptimiseStore, nix::CmdPathFromHashPart, nix::CmdPathInfo, nix::CmdPrintDevEnv, nix::CmdProfile, nix::CmdProfileAdd, nix::CmdProfileDiffClosures, nix::CmdProfileHistory, nix::CmdProfileList, nix::CmdProfileRemove, nix::CmdProfileRollback, nix::CmdProfileUpgrade, nix::CmdProfileWipeHistory, nix::CmdRegistry, nix::CmdRegistryAdd, nix::CmdRegistryList, nix::CmdRegistryPin, nix::CmdRegistryRemove, nix::CmdRegistryResolve, nix::CmdRepl, nix::CmdRootsDaemon, nix::CmdRun, nix::CmdSearch, nix::CmdShell, nix::CmdShowDerivation, nix::CmdStoreDelete, nix::CmdStoreGC, nix::CmdStorePrefetchFile, nix::CmdStoreRepair, nix::CmdSubmitOutput, nix::CmdUpgradeNix, nix::CmdVerify, nix::CmdVersion, nix::CmdWhyDepends, and nix::NixArgs.
|
inline |
Expect a path argument.
|
inline |
Expect a string argument.
|
inline |
Expect 0 or more arguments.
|
virtual |
Get the base directory for the command.
This only returns the correct value after parseCmdline() has run.
Reimplemented in nix::RootArgs.
| RootArgs & nix::Args::getRoot | ( | ) |
Traverse parent pointers until we find the rootarguments object.
|
inlineprotectedvirtual |
Called after all command line flags before the first non-flag argument (if any) have been processed.
|
protectedvirtual |
Process some positional arguments
| 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.
|
protectedvirtual |
Process a single flag and its arguments, pulling from an iterator of raw CLI args as needed.
Reimplemented in nix::LegacyArgs, and nix::MultiCommand.
|
staticprotected |
The largest size_t is used to indicate the "any" arity, for handlers/flags/arguments that accept an arbitrary number of arguments.
|
protected |
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.
|
protected |
Index of all registered "long" flag descriptions (flags like --long).
| MultiCommand* nix::Args::parent = nullptr |
|
protected |
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.
|
protected |
Index of all registered "short" flag descriptions (flags like -s).