diff options
author | Shea Levy <shea@shealevy.com> | 2018-03-02T16·41-0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-03-02T16·41-0500 |
commit | 3748a0ca1e9406ff4a701b4f0e1f506c008c4137 (patch) | |
tree | 0c16380b5cfb273a871d68ec24f70b9c50fd135e /src | |
parent | aa8bbbf69dfb7a1cd02237fee65c2fce39d27556 (diff) | |
parent | 0413aeb35d6ee869a98b6565781c1cf47dc80080 (diff) |
Merge branch 'improve-search-algorithm' of git://github.com/Ma27/nix
Diffstat (limited to 'src')
-rw-r--r-- | src/nix/search.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc index 87cdb2d7ed8a..0fbd3b6c073a 100644 --- a/src/nix/search.cc +++ b/src/nix/search.cc @@ -82,8 +82,6 @@ struct CmdSearch : SourceExprCommand, MixJSON auto state = getEvalState(); - bool first = true; - auto jsonOut = json ? std::make_unique<JSONObject>(std::cout) : nullptr; auto sToplevel = state->symbols.create("_toplevel"); @@ -91,6 +89,8 @@ struct CmdSearch : SourceExprCommand, MixJSON bool fromCache = false; + std::map<std::string, std::string> results; + std::function<void(Value *, std::string, bool, JSONObject *)> doExpr; doExpr = [&](Value * v, std::string attrPath, bool toplevel, JSONObject * cache) { @@ -138,10 +138,7 @@ struct CmdSearch : SourceExprCommand, MixJSON jsonElem.attr("description", description); } else { - if (!first) std::cout << "\n"; - first = false; - - std::cout << fmt( + results[attrPath] = fmt( "Attribute name: %s\n" "Package name: %s\n" "Version: %s\n" @@ -240,6 +237,9 @@ struct CmdSearch : SourceExprCommand, MixJSON if (rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1) throw SysError("cannot rename '%s' to '%s'", tmpFile, jsonCacheFileName); } + + for (auto el : results) std::cout << el.second << "\n"; + } }; |