diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-09-13T22·05-0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-09-13T22·05-0400 |
commit | 9fd9dedf12bb64e02b35e9231173f9ebae5e1492 (patch) | |
tree | 6dd72e499176960e043ac8db4f9259674f8713bd /src/nix-env/nix-env.cc | |
parent | 1bda006b748ffec371096af56a8fbf7125658f71 (diff) |
nix-env --delete-generations: Support --dry-run flag
Fixes #43.
Diffstat (limited to 'src/nix-env/nix-env.cc')
-rw-r--r-- | src/nix-env/nix-env.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 5174daf90d86..dd2fa30481f7 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -1205,10 +1205,15 @@ static void opListGenerations(Globals & globals, } -static void deleteGeneration2(const Path & profile, unsigned int gen) +static void deleteGeneration2(Globals & globals, unsigned int gen) { - printMsg(lvlInfo, format("removing generation %1%") % gen); - deleteGeneration(profile, gen); + if (globals.dryRun) + printMsg(lvlInfo, format("would remove generation %1%") % gen); + else { + printMsg(lvlInfo, format("removing generation %1%") % gen); + deleteGeneration(globals.profile, gen); + } + } @@ -1229,7 +1234,7 @@ static void opDeleteGenerations(Globals & globals, if (*i == "old") { for (Generations::iterator j = gens.begin(); j != gens.end(); ++j) if (j->number != curGen) - deleteGeneration2(globals.profile, j->number); + deleteGeneration2(globals, j->number); } else { @@ -1239,7 +1244,7 @@ static void opDeleteGenerations(Globals & globals, bool found = false; for (Generations::iterator j = gens.begin(); j != gens.end(); ++j) { if (j->number == n) { - deleteGeneration2(globals.profile, j->number); + deleteGeneration2(globals, j->number); found = true; break; } |