mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
Format
This commit is contained in:
parent
c692f6af13
commit
d93cc11491
1 changed files with 29 additions and 21 deletions
|
@ -6,15 +6,20 @@ using namespace nix;
|
||||||
|
|
||||||
struct CmdEnv : NixMultiCommand
|
struct CmdEnv : NixMultiCommand
|
||||||
{
|
{
|
||||||
CmdEnv() : NixMultiCommand("env", RegisterCommand::getCommandsFor({"env"}))
|
CmdEnv()
|
||||||
{ }
|
: NixMultiCommand("env", RegisterCommand::getCommandsFor({"env"}))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
{
|
{
|
||||||
return "manipulate the process environment";
|
return "manipulate the process environment";
|
||||||
}
|
}
|
||||||
|
|
||||||
Category category() override { return catUtility; }
|
Category category() override
|
||||||
|
{
|
||||||
|
return catUtility;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto rCmdEnv = registerCommand<CmdEnv>("env");
|
static auto rCmdEnv = registerCommand<CmdEnv>("env");
|
||||||
|
@ -24,20 +29,20 @@ struct CmdShell : InstallablesCommand, MixEnvironment
|
||||||
|
|
||||||
using InstallablesCommand::run;
|
using InstallablesCommand::run;
|
||||||
|
|
||||||
std::vector<std::string> command = { getEnv("SHELL").value_or("bash") };
|
std::vector<std::string> command = {getEnv("SHELL").value_or("bash")};
|
||||||
|
|
||||||
CmdShell()
|
CmdShell()
|
||||||
{
|
{
|
||||||
addFlag({
|
addFlag(
|
||||||
.longName = "command",
|
{.longName = "command",
|
||||||
.shortName = 'c',
|
.shortName = 'c',
|
||||||
.description = "Command and arguments to be executed, defaulting to `$SHELL`",
|
.description = "Command and arguments to be executed, defaulting to `$SHELL`",
|
||||||
.labels = {"command", "args"},
|
.labels = {"command", "args"},
|
||||||
.handler = {[&](std::vector<std::string> ss) {
|
.handler = {[&](std::vector<std::string> ss) {
|
||||||
if (ss.empty()) throw UsageError("--command requires at least one argument");
|
if (ss.empty())
|
||||||
command = ss;
|
throw UsageError("--command requires at least one argument");
|
||||||
}}
|
command = ss;
|
||||||
});
|
}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
|
@ -48,19 +53,21 @@ struct CmdShell : InstallablesCommand, MixEnvironment
|
||||||
std::string doc() override
|
std::string doc() override
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
#include "shell.md"
|
#include "shell.md"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(ref<Store> store, Installables && installables) override
|
void run(ref<Store> store, Installables && installables) override
|
||||||
{
|
{
|
||||||
auto outPaths = Installable::toStorePaths(getEvalStore(), store, Realise::Outputs, OperateOn::Output, installables);
|
auto outPaths =
|
||||||
|
Installable::toStorePaths(getEvalStore(), store, Realise::Outputs, OperateOn::Output, installables);
|
||||||
|
|
||||||
auto accessor = store->getFSAccessor();
|
auto accessor = store->getFSAccessor();
|
||||||
|
|
||||||
std::unordered_set<StorePath> done;
|
std::unordered_set<StorePath> done;
|
||||||
std::queue<StorePath> todo;
|
std::queue<StorePath> todo;
|
||||||
for (auto & path : outPaths) todo.push(path);
|
for (auto & path : outPaths)
|
||||||
|
todo.push(path);
|
||||||
|
|
||||||
setEnviron();
|
setEnviron();
|
||||||
|
|
||||||
|
@ -69,7 +76,8 @@ struct CmdShell : InstallablesCommand, MixEnvironment
|
||||||
while (!todo.empty()) {
|
while (!todo.empty()) {
|
||||||
auto path = todo.front();
|
auto path = todo.front();
|
||||||
todo.pop();
|
todo.pop();
|
||||||
if (!done.insert(path).second) continue;
|
if (!done.insert(path).second)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (true)
|
if (true)
|
||||||
pathAdditions.push_back(store->printStorePath(path) + "/bin");
|
pathAdditions.push_back(store->printStorePath(path) + "/bin");
|
||||||
|
@ -88,11 +96,11 @@ struct CmdShell : InstallablesCommand, MixEnvironment
|
||||||
setEnv("PATH", unixPathString.c_str());
|
setEnv("PATH", unixPathString.c_str());
|
||||||
|
|
||||||
Strings args;
|
Strings args;
|
||||||
for (auto & arg : command) args.push_back(arg);
|
for (auto & arg : command)
|
||||||
|
args.push_back(arg);
|
||||||
|
|
||||||
runProgramInStore(store, UseLookupPath::Use, *command.begin(), args);
|
runProgramInStore(store, UseLookupPath::Use, *command.begin(), args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto rCmdShell = registerCommand2<CmdShell>({"env", "shell"});
|
static auto rCmdShell = registerCommand2<CmdShell>({"env", "shell"});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue