From 39087321811e81e26a1a47d6967df1088dcf0e95 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 19 May 2020 20:47:23 +0100 Subject: style(3p/nix): Final act in the brace-wrapping saga This last change set was generated by a full clang-tidy run (including compilation): clang-tidy -p ~/projects/nix-build/ \ -checks=-*,readability-braces-around-statements -fix src/*/*.cc Actually running clang-tidy requires some massaging to make it play nice with Nix + meson, I'll be adding a wrapper or something for that soon. --- third_party/nix/src/nix/command.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'third_party/nix/src/nix/command.cc') diff --git a/third_party/nix/src/nix/command.cc b/third_party/nix/src/nix/command.cc index 4c1220668c..b35fb1be98 100644 --- a/third_party/nix/src/nix/command.cc +++ b/third_party/nix/src/nix/command.cc @@ -14,10 +14,11 @@ void Command::printHelp(const string& programName, std::ostream& out) { if (!exs.empty()) { out << "\n"; out << "Examples:\n"; - for (auto& ex : exs) + for (auto& ex : exs) { out << "\n" << " " << ex.description << "\n" // FIXME: wrap << " $ " << ex.command << "\n"; + } } } @@ -26,8 +27,9 @@ MultiCommand::MultiCommand(const Commands& _commands) : commands(_commands) { "command", 1, true, [=](std::vector ss) { assert(!command); auto i = commands.find(ss[0]); - if (i == commands.end()) + if (i == commands.end()) { throw UsageError("'%s' is not a recognised command", ss[0]); + } command = i->second; }}); } @@ -50,8 +52,9 @@ void MultiCommand::printHelp(const string& programName, std::ostream& out) { Table2 table; for (auto& command : commands) { auto descr = command.second->description(); - if (!descr.empty()) + if (!descr.empty()) { table.push_back(std::make_pair(command.second->name(), descr)); + } } printTable(out, table); @@ -72,16 +75,19 @@ bool MultiCommand::processFlag(Strings::iterator& pos, Strings::iterator end) { } bool MultiCommand::processArgs(const Strings& args, bool finish) { - if (command) + if (command) { return command->processArgs(args, finish); - else + } else { return Args::processArgs(args, finish); + } } StoreCommand::StoreCommand() {} ref StoreCommand::getStore() { - if (!_store) _store = createStore(); + if (!_store) { + _store = createStore(); + } return ref(_store); } @@ -90,17 +96,18 @@ ref StoreCommand::createStore() { return openStore(); } void StoreCommand::run() { run(getStore()); } StorePathsCommand::StorePathsCommand(bool recursive) : recursive(recursive) { - if (recursive) + if (recursive) { mkFlag() .longName("no-recursive") .description("apply operation to specified paths only") .set(&this->recursive, false); - else + } else { mkFlag() .longName("recursive") .shortName('r') .description("apply operation to closure of the specified paths") .set(&this->recursive, true); + } mkFlag(0, "all", "apply operation to the entire store", &all); } @@ -109,16 +116,18 @@ void StorePathsCommand::run(ref store) { Paths storePaths; if (all) { - if (installables.size()) + if (installables.size()) { throw UsageError("'--all' does not expect arguments"); + } for (auto& p : store->queryAllValidPaths()) { storePaths.push_back(p); } } else { - for (auto& p : toStorePaths(store, NoBuild, installables)) + for (auto& p : toStorePaths(store, NoBuild, installables)) { storePaths.push_back(p); + } if (recursive) { PathSet closure; @@ -134,8 +143,9 @@ void StorePathsCommand::run(ref store) { void StorePathCommand::run(ref store) { auto storePaths = toStorePaths(store, NoBuild, installables); - if (storePaths.size() != 1) + if (storePaths.size() != 1) { throw UsageError("this command requires exactly one store path"); + } run(store, *storePaths.begin()); } -- cgit 1.4.1