aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd
diff options
context:
space:
mode:
authorTom Bereknyei <tomberek@gmail.com>2022-03-11 13:26:08 -0500
committerTom Bereknyei <tomberek@gmail.com>2022-05-18 21:20:59 -0400
commit5640b528349c43717aa501797a4f337373ebf3e4 (patch)
treedafde5d19c66eac53a077604db1d5f73b71ba0a3 /src/libcmd
parent81567a096258026148b42f3048be9b2ba295b41a (diff)
repl: use installables
Diffstat (limited to 'src/libcmd')
-rw-r--r--src/libcmd/command.hh2
-rw-r--r--src/libcmd/installables.cc12
-rw-r--r--src/libcmd/installables.hh1
3 files changed, 9 insertions, 6 deletions
diff --git a/src/libcmd/command.hh b/src/libcmd/command.hh
index 65626e33f..65eb0c4a0 100644
--- a/src/libcmd/command.hh
+++ b/src/libcmd/command.hh
@@ -114,6 +114,7 @@ struct InstallablesCommand : virtual Args, SourceExprCommand
InstallablesCommand();
void prepare() override;
+ Installables load();
virtual bool useDefaultInstallables() { return true; }
@@ -132,7 +133,6 @@ struct InstallableCommand : virtual Args, SourceExprCommand
InstallableCommand(bool supportReadOnlyMode = false);
void prepare() override;
- std::shared_ptr<Installable> load();
std::optional<FlakeRef> getFlakeRefForCompletion() override
{
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 7d2ff0f68..c29fbeec9 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -1025,11 +1025,16 @@ InstallablesCommand::InstallablesCommand()
void InstallablesCommand::prepare()
{
+ installables = load();
+}
+
+Installables InstallablesCommand::load() {
+ Installables installables;
if (_installables.empty() && useDefaultInstallables())
// FIXME: commands like "nix profile install" should not have a
// default, probably.
_installables.push_back(".");
- installables = parseInstallables(getStore(), _installables);
+ return parseInstallables(getStore(), _installables);
}
std::optional<FlakeRef> InstallablesCommand::getFlakeRefForCompletion()
@@ -1054,13 +1059,10 @@ InstallableCommand::InstallableCommand(bool supportReadOnlyMode)
}}
});
}
-std::shared_ptr<Installable> InstallableCommand::load() {
- return parseInstallable(getStore(), _installable);
-}
void InstallableCommand::prepare()
{
- installable = load();
+ installable = parseInstallable(getStore(), _installable);
}
}
diff --git a/src/libcmd/installables.hh b/src/libcmd/installables.hh
index 5d715210e..b97888db6 100644
--- a/src/libcmd/installables.hh
+++ b/src/libcmd/installables.hh
@@ -131,6 +131,7 @@ struct Installable
OperateOn operateOn,
const std::vector<std::shared_ptr<Installable>> & installables);
};
+typedef std::vector<std::shared_ptr<Installable>> Installables;
struct InstallableValue : Installable
{