Skip to content

Commit

Permalink
Merge branch 'pr545' into stable
Browse files Browse the repository at this point in the history
* pr545:
  (GH-551) Unset Configuration Values

Closes #545
  • Loading branch information
ferventcoder committed Jan 18, 2016
2 parents d3f8e4e + ae2e997 commit 2e98de3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ public void should_call_service_source_enable_when_command_is_enable()
because();
configSettingsService.Verify(c => c.config_set(configuration), Times.Once);
}

[Fact]
public void should_call_service_source_unset_when_command_is_unset()
{
configuration.ConfigCommand.Command = ConfigCommandType.unset;
because();
configSettingsService.Verify(c => c.config_unset(configuration), Times.Once);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Chocolatey will allow you to interact with the configuration file settings.

"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
choco config [list]|get|set [<options/switches>]
choco config [list]|get|set|unset [<options/switches>]
");

"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
Expand All @@ -107,6 +107,8 @@ choco config get cacheLocation
choco config get --name cacheLocation
choco config set cacheLocation c:\temp\choco
choco config set --name cacheLocation --value c:\temp\choco
choco config unset proxy
choco config unset --name proxy
");

"chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches");
Expand All @@ -130,6 +132,9 @@ public void run(ChocolateyConfiguration configuration)
case ConfigCommandType.set:
_configSettingsService.config_set(configuration);
break;
case ConfigCommandType.unset:
_configSettingsService.config_unset(configuration);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public enum ConfigCommandType
list,
get,
set,
unset,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,5 +356,21 @@ public void config_set(ChocolateyConfiguration configuration)
}
}
}

public void config_unset(ChocolateyConfiguration configuration)
{
var config = config_get(configuration.ConfigCommand.Name);
if (config == null || string.IsNullOrEmpty(config.Value))
{
this.Log().Warn(NO_CHANGE_MESSAGE);
}
else
{
config.Value = "";
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);

this.Log().Warn(() => "Unset {0}".format_with(config.Key));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public interface IChocolateyConfigSettingsService
void config_list(ChocolateyConfiguration configuration);
void config_get(ChocolateyConfiguration configuration);
void config_set(ChocolateyConfiguration configuration);
void config_unset(ChocolateyConfiguration configuration);
}
}

0 comments on commit 2e98de3

Please sign in to comment.