diff --git a/lix/libcmd/command.cc b/lix/libcmd/command.cc index b6a6e064b..4dd5fdb67 100644 --- a/lix/libcmd/command.cc +++ b/lix/libcmd/command.cc @@ -28,12 +28,6 @@ nix::Commands RegisterCommand::getCommandsFor(const std::vector & p return res; } -nlohmann::json NixMultiCommand::toJSON() -{ - // FIXME: use Command::toJSON() as well. - return MultiCommand::toJSON(); -} - StoreCommand::StoreCommand() { } diff --git a/lix/libcmd/command.hh b/lix/libcmd/command.hh index 27f242f54..29b47cbac 100644 --- a/lix/libcmd/command.hh +++ b/lix/libcmd/command.hh @@ -26,11 +26,6 @@ static constexpr Command::Category catNixInstallation = 102; static constexpr auto installablesCategory = "Options that change the interpretation of [installables](@docroot@/command-ref/new-cli/nix.md#installables)"; -struct NixMultiCommand : virtual MultiCommand, virtual Command -{ - nlohmann::json toJSON() override; -}; - // For the overloaded run methods #pragma GCC diagnostic ignored "-Woverloaded-virtual" diff --git a/lix/libutil/args.cc b/lix/libutil/args.cc index 92b24df20..ee9fa6b72 100644 --- a/lix/libutil/args.cc +++ b/lix/libutil/args.cc @@ -440,6 +440,8 @@ bool MultiCommand::processArgs(const Strings & args, bool finish) nlohmann::json MultiCommand::toJSON() { + // FIXME: use Command::toJSON() as well. + auto cmds = nlohmann::json::object(); for (auto & [name, commandFun] : commands) { diff --git a/lix/libutil/args.hh b/lix/libutil/args.hh index dcec2ccbc..681d9c426 100644 --- a/lix/libutil/args.hh +++ b/lix/libutil/args.hh @@ -343,7 +343,7 @@ typedef std::map()>> Commands; * An argument parser that supports multiple subcommands, * i.e. ‘ ’. */ -class MultiCommand : virtual public Args +class MultiCommand : public Command { public: Commands commands; diff --git a/lix/nix/config.cc b/lix/nix/config.cc index 67fcd9f4f..5f744e9ec 100644 --- a/lix/nix/config.cc +++ b/lix/nix/config.cc @@ -7,7 +7,7 @@ using namespace nix; -struct CmdConfig : virtual NixMultiCommand +struct CmdConfig : virtual MultiCommand { CmdConfig() : MultiCommand(RegisterCommand::getCommandsFor({"config"})) { } diff --git a/lix/nix/derivation.cc b/lix/nix/derivation.cc index 2d1717f0c..8df5e64c6 100644 --- a/lix/nix/derivation.cc +++ b/lix/nix/derivation.cc @@ -2,7 +2,7 @@ using namespace nix; -struct CmdDerivation : virtual NixMultiCommand +struct CmdDerivation : virtual MultiCommand { CmdDerivation() : MultiCommand(RegisterCommand::getCommandsFor({"derivation"})) { } diff --git a/lix/nix/flake.cc b/lix/nix/flake.cc index 61acbeacc..47a2573c0 100644 --- a/lix/nix/flake.cc +++ b/lix/nix/flake.cc @@ -1464,7 +1464,7 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON } }; -struct CmdFlake : NixMultiCommand +struct CmdFlake : MultiCommand { CmdFlake() : MultiCommand({ diff --git a/lix/nix/hash.cc b/lix/nix/hash.cc index 94bbe86ac..fbabe0345 100644 --- a/lix/nix/hash.cc +++ b/lix/nix/hash.cc @@ -124,7 +124,7 @@ struct CmdToBase : Command } }; -struct CmdHash : NixMultiCommand +struct CmdHash : MultiCommand { CmdHash() : MultiCommand({ diff --git a/lix/nix/main.cc b/lix/nix/main.cc index b464808fc..826b4f238 100644 --- a/lix/nix/main.cc +++ b/lix/nix/main.cc @@ -214,6 +214,11 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs ; } + void run() override + { + command->second->run(); + } + // Plugins may add new subcommands. void pluginsInited() override { @@ -528,7 +533,7 @@ void mainWrapped(int argc, char * * argv) if (args.command->second->forceImpureByDefault()) { evalSettings.pureEval.setDefault(false); } - args.command->second->run(); + args.run(); } } diff --git a/lix/nix/nar.cc b/lix/nix/nar.cc index 5954c680f..2061b0f1f 100644 --- a/lix/nix/nar.cc +++ b/lix/nix/nar.cc @@ -2,7 +2,7 @@ using namespace nix; -struct CmdNar : NixMultiCommand +struct CmdNar : MultiCommand { CmdNar() : MultiCommand(RegisterCommand::getCommandsFor({"nar"})) { } diff --git a/lix/nix/profile.cc b/lix/nix/profile.cc index 9878ca514..d5d20ce71 100644 --- a/lix/nix/profile.cc +++ b/lix/nix/profile.cc @@ -601,7 +601,7 @@ struct CmdProfileWipeHistory : virtual StoreCommand, MixDefaultProfile, MixDryRu } }; -struct CmdProfile : NixMultiCommand +struct CmdProfile : MultiCommand { CmdProfile() : MultiCommand({ diff --git a/lix/nix/realisation.cc b/lix/nix/realisation.cc index 9ed910f45..80308e99f 100644 --- a/lix/nix/realisation.cc +++ b/lix/nix/realisation.cc @@ -5,7 +5,7 @@ using namespace nix; -struct CmdRealisation : virtual NixMultiCommand +struct CmdRealisation : virtual MultiCommand { CmdRealisation() : MultiCommand(RegisterCommand::getCommandsFor({"realisation"})) { } diff --git a/lix/nix/registry.cc b/lix/nix/registry.cc index d0e9a8f2f..5bdba362b 100644 --- a/lix/nix/registry.cc +++ b/lix/nix/registry.cc @@ -204,7 +204,7 @@ struct CmdRegistryPin : RegistryCommand, EvalCommand } }; -struct CmdRegistry : virtual NixMultiCommand +struct CmdRegistry : virtual MultiCommand { CmdRegistry() : MultiCommand({ diff --git a/lix/nix/sigs.cc b/lix/nix/sigs.cc index d84b0e10a..9a63e19cf 100644 --- a/lix/nix/sigs.cc +++ b/lix/nix/sigs.cc @@ -199,7 +199,7 @@ struct CmdKeyConvertSecretToPublic : Command } }; -struct CmdKey : NixMultiCommand +struct CmdKey : MultiCommand { CmdKey() : MultiCommand({ diff --git a/lix/nix/store.cc b/lix/nix/store.cc index 98ff26870..00f980088 100644 --- a/lix/nix/store.cc +++ b/lix/nix/store.cc @@ -2,7 +2,7 @@ using namespace nix; -struct CmdStore : virtual NixMultiCommand +struct CmdStore : virtual MultiCommand { CmdStore() : MultiCommand(RegisterCommand::getCommandsFor({"store"})) { }