diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..099b1d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.in +*.o +*/.deps + +compile +config.* +configure +depcomp +install-sh +missing diff --git a/src/cellar.cpp b/src/cellar.cpp index 768108d..853959d 100644 --- a/src/cellar.cpp +++ b/src/cellar.cpp @@ -1,20 +1,44 @@ #include +#include #include #include +#include #include #include #include +#include "json.hpp" #include "fs.hpp" using namespace std; +using json = nlohmann::json; int main(int argc, char* argv[]) { - vector homedir = cellar::fs::listdir(getenv("HOME")); + string homepath = getenv("HOME"); + vector homedir = cellar::fs::listdir(homepath); for (string item : homedir) { - cout << item; - cout << " "; + if (item.substr(0,5) == ".wine") { + cout << item; + cout << " "; + + string jsonpath = homepath + "/" + item + "/cellar.json"; + if (boost::filesystem::exists(jsonpath)) { + try { + json config; + ifstream configstream(jsonpath); + stringstream sstr; + sstr << configstream.rdbuf(); + config = json::parse(sstr.str()); + + cout << "has a json" << endl; + } + catch (const exception &exc) { + cout << "- bogus cellar.json file" << endl; + } + } + else { cout << "- anonymous wine bottle" << endl; } + } } cout << endl; return 0;