aboutsummaryrefslogtreecommitdiff
path: root/src/nix/flake.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-06-18 16:01:35 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-06-18 16:25:31 +0200
commita0de58f471c9087d8e6cc60a6078f9940a125b15 (patch)
tree45211b7ecd10f372c9a4a8e4b6cba7a30560ce21 /src/nix/flake.cc
parenteb18aedccbc0d01b6a5cc720ce1befd0b316aebf (diff)
Make subcommand construction in MultiCommand lazy
Diffstat (limited to 'src/nix/flake.cc')
-rw-r--r--src/nix/flake.cc79
1 files changed, 12 insertions, 67 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 6fc56827f..91c6b4276 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -49,11 +49,6 @@ public:
struct CmdFlakeList : EvalCommand
{
- std::string name() override
- {
- return "list";
- }
-
std::string description() override
{
return "list available Nix flakes";
@@ -133,11 +128,6 @@ static void printNonFlakeInfo(const NonFlake & nonFlake)
// FIXME: merge info CmdFlakeInfo?
struct CmdFlakeDeps : FlakeCommand
{
- std::string name() override
- {
- return "deps";
- }
-
std::string description() override
{
return "list informaton about dependencies";
@@ -171,11 +161,6 @@ struct CmdFlakeDeps : FlakeCommand
struct CmdFlakeUpdate : FlakeCommand
{
- std::string name() override
- {
- return "update";
- }
-
std::string description() override
{
return "update flake lock file";
@@ -209,11 +194,6 @@ static void enumerateOutputs(EvalState & state, Value & vFlake,
struct CmdFlakeInfo : FlakeCommand, MixJSON
{
- std::string name() override
- {
- return "info";
- }
-
std::string description() override
{
return "list info about a given flake";
@@ -269,11 +249,6 @@ struct CmdFlakeCheck : FlakeCommand, MixJSON
.set(&build, false);
}
- std::string name() override
- {
- return "check";
- }
-
std::string description() override
{
return "check whether the flake evaluates and run its tests";
@@ -383,11 +358,6 @@ struct CmdFlakeAdd : MixEvalArgs, Command
FlakeUri alias;
FlakeUri uri;
- std::string name() override
- {
- return "add";
- }
-
std::string description() override
{
return "upsert flake in user flake registry";
@@ -414,11 +384,6 @@ struct CmdFlakeRemove : virtual Args, MixEvalArgs, Command
{
FlakeUri alias;
- std::string name() override
- {
- return "remove";
- }
-
std::string description() override
{
return "remove flake from user flake registry";
@@ -442,11 +407,6 @@ struct CmdFlakePin : virtual Args, EvalCommand
{
FlakeUri alias;
- std::string name() override
- {
- return "pin";
- }
-
std::string description() override
{
return "pin flake require in user flake registry";
@@ -482,11 +442,6 @@ struct CmdFlakePin : virtual Args, EvalCommand
struct CmdFlakeInit : virtual Args, Command
{
- std::string name() override
- {
- return "init";
- }
-
std::string description() override
{
return "create a skeleton 'flake.nix' file in the current directory";
@@ -514,11 +469,6 @@ struct CmdFlakeClone : FlakeCommand
{
Path destDir;
- std::string name() override
- {
- return "clone";
- }
-
std::string description() override
{
return "clone flake repository";
@@ -541,23 +491,18 @@ struct CmdFlakeClone : FlakeCommand
struct CmdFlake : virtual MultiCommand, virtual Command
{
CmdFlake()
- : MultiCommand({make_ref<CmdFlakeList>()
- , make_ref<CmdFlakeUpdate>()
- , make_ref<CmdFlakeInfo>()
- , make_ref<CmdFlakeCheck>()
- //, make_ref<CmdFlakeDeps>()
- , make_ref<CmdFlakeAdd>()
- , make_ref<CmdFlakeRemove>()
- , make_ref<CmdFlakePin>()
- , make_ref<CmdFlakeInit>()
- , make_ref<CmdFlakeClone>()
- })
- {
- }
-
- std::string name() override
+ : MultiCommand({
+ {"list", []() { return make_ref<CmdFlakeList>(); }},
+ {"update", []() { return make_ref<CmdFlakeUpdate>(); }},
+ {"info", []() { return make_ref<CmdFlakeInfo>(); }},
+ {"check", []() { return make_ref<CmdFlakeCheck>(); }},
+ {"add", []() { return make_ref<CmdFlakeAdd>(); }},
+ {"remove", []() { return make_ref<CmdFlakeRemove>(); }},
+ {"pin", []() { return make_ref<CmdFlakePin>(); }},
+ {"init", []() { return make_ref<CmdFlakeInit>(); }},
+ {"clone", []() { return make_ref<CmdFlakeClone>(); }},
+ })
{
- return "flake";
}
std::string description() override
@@ -578,4 +523,4 @@ struct CmdFlake : virtual MultiCommand, virtual Command
}
};
-static RegisterCommand r1(make_ref<CmdFlake>());
+static auto r1 = registerCommand<CmdFlake>("flake");