cellar config set is now effective
This commit is contained in:
		@@ -31,14 +31,34 @@ void cellar::bottles::config_command(int argc, vector<string> argv) {
 | 
			
		||||
        Bottle active_bottle = Bottle(homedir + "/.wine");
 | 
			
		||||
        active_bottle.load_config();
 | 
			
		||||
 | 
			
		||||
        string value = active_bottle.get_config(argv[2]);
 | 
			
		||||
        string key = argv[2];
 | 
			
		||||
        string value = active_bottle.get_config(key);
 | 
			
		||||
        
 | 
			
		||||
        if (value != "") {
 | 
			
		||||
            output::statement(argv[2] + ": " + value);
 | 
			
		||||
            output::statement(key + ": " + value);
 | 
			
		||||
        } else {
 | 
			
		||||
            output::error(argv[2] + " is not defined");
 | 
			
		||||
            output::error(key + " is not defined");
 | 
			
		||||
        }
 | 
			
		||||
    } else if (command == "set") {
 | 
			
		||||
        output::statement("usage: " + argv[0] + " set <key> <value>");
 | 
			
		||||
        if (argc < 4) {
 | 
			
		||||
            output::statement("usage: " + argv[0] + " set <key> <value>");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TEMP
 | 
			
		||||
        string homedir = getenv("HOME");
 | 
			
		||||
        Bottle active_bottle = Bottle(homedir + "/.wine");
 | 
			
		||||
        active_bottle.load_config();
 | 
			
		||||
 | 
			
		||||
        string key = argv[2];
 | 
			
		||||
        string newvalue = argv[3];
 | 
			
		||||
        string oldvalue = active_bottle.get_config(key);
 | 
			
		||||
 | 
			
		||||
        if (active_bottle.set_config(key, newvalue)) {
 | 
			
		||||
            output::statement(key + ": " + newvalue + " (was " + oldvalue + ")");
 | 
			
		||||
        } else {
 | 
			
		||||
            output::error(key + ": " + oldvalue);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        output::statement("usage is one of:");
 | 
			
		||||
        output::statement("\t" + argv[0] + " get <key>");
 | 
			
		||||
 
 | 
			
		||||
@@ -58,5 +58,6 @@ string Bottle::get_config(string key) {
 | 
			
		||||
 | 
			
		||||
bool Bottle::set_config(string key, string value) {
 | 
			
		||||
    this->config[key] = value;
 | 
			
		||||
    this->save_config();
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ void cellar::output::warning(string str_message, bool verbose) {
 | 
			
		||||
    
 | 
			
		||||
    cerr << str_message << endl;
 | 
			
		||||
}
 | 
			
		||||
void cellar::output::warning(string str_message) { statement(str_message, false); }
 | 
			
		||||
void cellar::output::warning(string str_message) { warning(str_message, false); }
 | 
			
		||||
 | 
			
		||||
void cellar::output::error(string str_message, bool verbose) {
 | 
			
		||||
    if (verbose and !cellar::verbose) { return; }
 | 
			
		||||
@@ -64,5 +64,5 @@ void cellar::output::error(string str_message, bool verbose) {
 | 
			
		||||
    
 | 
			
		||||
    cerr << str_message << endl;
 | 
			
		||||
}
 | 
			
		||||
void cellar::output::error(string str_message) { statement(str_message, false); }
 | 
			
		||||
void cellar::output::error(string str_message) { error(str_message, false); }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user