list command
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
bin_PROGRAMS = cellar
 | 
			
		||||
cellar_CPPFLAGS = $(BOOST_CPPFLAGS)
 | 
			
		||||
cellar_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB)
 | 
			
		||||
cellar_SOURCES = cellar.cpp fs.cpp bottles.cpp commands.cpp
 | 
			
		||||
cellar_SOURCES = commands.cpp cellar.cpp fs.cpp bottles.cpp
 | 
			
		||||
 | 
			
		||||
# Generated files
 | 
			
		||||
nodist_cellar_SOURCES = version.cpp
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
#include "json.hpp"
 | 
			
		||||
 | 
			
		||||
#include "bottles.hpp"
 | 
			
		||||
#include "commands.hpp"
 | 
			
		||||
#include "fs.hpp"
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
@@ -30,7 +31,7 @@ map<string, Bottle> cellar::bottles::get_bottles() {
 | 
			
		||||
	string homepath = getenv("HOME");
 | 
			
		||||
	vector<string> homedir = cellar::fs::listdir(homepath);
 | 
			
		||||
	for (string item : homedir) {
 | 
			
		||||
		if (item.substr(0,5) == ".wine") {
 | 
			
		||||
		if (item.substr(0,6) == ".wine.") {
 | 
			
		||||
            Bottle output;
 | 
			
		||||
 | 
			
		||||
            string fullitem = homepath + "/" + item;
 | 
			
		||||
@@ -71,3 +72,27 @@ map<string, Bottle> cellar::bottles::get_bottles() {
 | 
			
		||||
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_bottles(int argc, char** argv) {
 | 
			
		||||
    map<string, Bottle> bottles = get_bottles();
 | 
			
		||||
 | 
			
		||||
    for (auto item : bottles) {
 | 
			
		||||
        Bottle bottle = item.second;
 | 
			
		||||
        cout << item.first << " - ";
 | 
			
		||||
        switch (bottle.type) {
 | 
			
		||||
            case bottle_anonymous:
 | 
			
		||||
                cout << "anonymous wine bottle";
 | 
			
		||||
                break;
 | 
			
		||||
            case bottle_symlink:
 | 
			
		||||
                cout << "symlink to " << bottle.canonical_path;
 | 
			
		||||
                break;
 | 
			
		||||
            case bottle_labelled:
 | 
			
		||||
                cout << bottle.config["name"];
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                cout << "broken or unsupported wine bottle";
 | 
			
		||||
        }
 | 
			
		||||
        cout << endl;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
cellar::commands::CommandFunction listcmd = cellar::commands::command_map["list"] = &print_bottles;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user