mirror of
https://github.com/NixOS/nix
synced 2025-06-28 13:41:15 +02:00
Initialize plugins after handling initial command line flags
This is technically a breaking change, since attempting to set plugin files after the first non-flag argument will now throw an error. This is acceptable given the relative lack of stability in a plugin interface and the need to tie the knot somewhere once plugins can actually define new subcommands.
This commit is contained in:
parent
ec3497c1d6
commit
98d1b64400
18 changed files with 36 additions and 22 deletions
|
@ -60,6 +60,7 @@ void Args::parseCmdline(const Strings & _cmdline)
|
|||
verbosity = lvlError;
|
||||
}
|
||||
|
||||
bool argsSeen = false;
|
||||
for (auto pos = cmdline.begin(); pos != cmdline.end(); ) {
|
||||
|
||||
auto arg = *pos;
|
||||
|
@ -88,6 +89,10 @@ void Args::parseCmdline(const Strings & _cmdline)
|
|||
throw UsageError("unrecognised flag '%1%'", arg);
|
||||
}
|
||||
else {
|
||||
if (!argsSeen) {
|
||||
argsSeen = true;
|
||||
initialFlagsProcessed();
|
||||
}
|
||||
pos = rewriteArgs(cmdline, pos);
|
||||
pendingArgs.push_back(*pos++);
|
||||
if (processArgs(pendingArgs, false))
|
||||
|
@ -96,6 +101,9 @@ void Args::parseCmdline(const Strings & _cmdline)
|
|||
}
|
||||
|
||||
processArgs(pendingArgs, true);
|
||||
|
||||
if (!argsSeen)
|
||||
initialFlagsProcessed();
|
||||
}
|
||||
|
||||
bool Args::processFlag(Strings::iterator & pos, Strings::iterator end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue