Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-551) Unset Configuration Values
  • Loading branch information
ferventcoder committed Jan 18, 2016
2 parents 9e901cc + 2e98de3 commit 6d8fbdd
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 6d8fbdd

Please sign in to comment.