list command
This commit is contained in:
parent
7f5e6088cf
commit
44a831a4b0
2
cogrc
2
cogrc
@ -1,3 +1,3 @@
|
|||||||
[version]
|
[version]
|
||||||
release=no
|
release=no
|
||||||
release_version=0.3
|
release_version=00
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
bin_PROGRAMS = cellar
|
bin_PROGRAMS = cellar
|
||||||
cellar_CPPFLAGS = $(BOOST_CPPFLAGS)
|
cellar_CPPFLAGS = $(BOOST_CPPFLAGS)
|
||||||
cellar_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB)
|
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
|
# Generated files
|
||||||
nodist_cellar_SOURCES = version.cpp
|
nodist_cellar_SOURCES = version.cpp
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
#include "bottles.hpp"
|
#include "bottles.hpp"
|
||||||
|
#include "commands.hpp"
|
||||||
#include "fs.hpp"
|
#include "fs.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -30,7 +31,7 @@ map<string, Bottle> cellar::bottles::get_bottles() {
|
|||||||
string homepath = getenv("HOME");
|
string homepath = getenv("HOME");
|
||||||
vector<string> homedir = cellar::fs::listdir(homepath);
|
vector<string> homedir = cellar::fs::listdir(homepath);
|
||||||
for (string item : homedir) {
|
for (string item : homedir) {
|
||||||
if (item.substr(0,5) == ".wine") {
|
if (item.substr(0,6) == ".wine.") {
|
||||||
Bottle output;
|
Bottle output;
|
||||||
|
|
||||||
string fullitem = homepath + "/" + item;
|
string fullitem = homepath + "/" + item;
|
||||||
@ -71,3 +72,27 @@ map<string, Bottle> cellar::bottles::get_bottles() {
|
|||||||
|
|
||||||
return result;
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user