本文整理汇总了C#中ChocolateyConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ChocolateyConfiguration类的具体用法?C# ChocolateyConfiguration怎么用?C# ChocolateyConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChocolateyConfiguration类属于命名空间,在下文中一共展示了ChocolateyConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: help_message
public virtual void help_message(ChocolateyConfiguration configuration)
{
this.Log().Info(ChocolateyLoggers.Important, "Outdated Command");
this.Log().Info(@"
Returns a list of outdated packages.
NOTE: Available with 0.9.9.6+.
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
choco outdated [<options/switches>]
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
"chocolatey".Log().Info(@"
choco outdated
choco outdated -s https://somewhere/out/there
choco outdated -s ""'https://somewhere/protected'"" -u user -p pass
If you use `--source=https://somewhere/out/there`, it is
going to look for outdated packages only based on that source.
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "See It In Action");
"chocolatey".Log().Info(@"
choco outdated: https://raw.githubusercontent.com/wiki/chocolatey/choco/images/gifs/choco_outdated.gif
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches");
}
示例2: GetPackages
public static IEnumerable<IPackage> GetPackages(ChocolateyConfiguration configuration, ILogger nugetLogger)
{
var packageRepository = NugetCommon.GetRemoteRepository(configuration, nugetLogger);
IQueryable<IPackage> results = packageRepository.Search(configuration.Input, configuration.Prerelease);
if (configuration.AllVersions)
{
return results.Where(PackageExtensions.IsListed).OrderBy(p => p.Id);
}
if (configuration.Prerelease && packageRepository.SupportsPrereleasePackages)
{
results = results.Where(p => p.IsAbsoluteLatestVersion);
}
else
{
results = results.Where(p => p.IsLatestVersion);
}
if (configuration.ListCommand.Page.HasValue)
{
results = results.Skip(configuration.ListCommand.PageSize * configuration.ListCommand.Page.Value).Take(configuration.ListCommand.PageSize);
}
return results.OrderBy(p => p.Id)
.AsEnumerable()
.Where(PackageExtensions.IsListed)
.Where(p => configuration.Prerelease || p.IsReleaseVersion())
.distinct_last(PackageEqualityComparer.Id, PackageComparer.Version);
}
示例3: handle_additional_argument_parsing
public void handle_additional_argument_parsing(IList<string> unparsedArguments, ChocolateyConfiguration configuration)
{
configuration.Input = string.Join(" ", unparsedArguments);
if (string.IsNullOrWhiteSpace(configuration.NewCommand.Name))
{
configuration.NewCommand.Name = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault();
var property = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault().Split(new[] {'='}, StringSplitOptions.RemoveEmptyEntries);
if (property.Count() == 1)
{
configuration.NewCommand.TemplateProperties.Add(TemplateValues.NamePropertyName, configuration.NewCommand.Name);
}
}
foreach (var unparsedArgument in unparsedArguments.or_empty_list_if_null())
{
var property = unparsedArgument.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
if (property.Count() == 2)
{
var propName = property[0].trim_safe();
var propValue = property[1].trim_safe().remove_surrounding_quotes();
if (configuration.NewCommand.TemplateProperties.ContainsKey(propName))
{
this.Log().Warn(() => "A value for '{0}' has already been added with the value '{1}'. Ignoring {0}='{2}'.".format_with(propName, configuration.NewCommand.TemplateProperties[propName], propValue));
}
else
{
configuration.NewCommand.TemplateProperties.Add(propName, propValue);
}
}
}
}
示例4: feature_enable
public void feature_enable(ChocolateyConfiguration configuration)
{
var feature = configFileSettings.Features.FirstOrDefault(p => p.Name.is_equal_to(configuration.FeatureCommand.Name));
if (feature == null)
{
throw new ApplicationException("Feature '{0}' not found".format_with(configuration.FeatureCommand.Name));
}
if (!feature.Enabled || !feature.SetExplicitly)
{
if (feature.Enabled && !feature.SetExplicitly)
{
this.Log().Info(() => "{0} was enabled by default. Explicitly setting value.".format_with(feature.Name));
}
feature.Enabled = true;
feature.SetExplicitly = true;
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Enabled {0}".format_with(feature.Name));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
}
}
示例5: handle_additional_argument_parsing
public void handle_additional_argument_parsing(IList<string> unparsedArguments, ChocolateyConfiguration configuration)
{
configuration.Input = string.Join(" ", unparsedArguments);
var command = ConfigCommandType.unknown;
string unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault().to_string().Replace("-",string.Empty);
Enum.TryParse(unparsedCommand, true, out command);
if (command == ConfigCommandType.unknown)
{
if (!string.IsNullOrWhiteSpace(unparsedCommand)) this.Log().Warn("Unknown command {0}. Setting to list.".format_with(unparsedCommand));
command = ConfigCommandType.list;
}
configuration.ConfigCommand.Command = command;
if ((configuration.ConfigCommand.Command == ConfigCommandType.list
|| !string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name)
)
&& unparsedArguments.Count > 1) throw new ApplicationException("A single features command must be listed. Please see the help menu for those commands");
if (string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name) && unparsedArguments.Count >=2)
{
configuration.ConfigCommand.Name = unparsedArguments[1];
}
if (string.IsNullOrWhiteSpace(configuration.ConfigCommand.ConfigValue) && unparsedArguments.Count >= 3)
{
configuration.ConfigCommand.ConfigValue = unparsedArguments[2];
}
}
示例6: handle_validation
public void handle_validation(ChocolateyConfiguration configuration)
{
if (!string.IsNullOrWhiteSpace(configuration.ApiKeyCommand.Key) && string.IsNullOrWhiteSpace(configuration.Sources))
{
throw new ApplicationException("You must specify both 'source' and 'key' to set an api key.");
}
}
示例7: set_up_configuration
/// <summary>
/// Sets up the configuration based on arguments passed in, config file, and environment
/// </summary>
/// <param name="args">The arguments.</param>
/// <param name="config">The configuration.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="xmlService">The XML service.</param>
/// <param name="notifyWarnLoggingAction">Notify warn logging action</param>
public static void set_up_configuration(IList<string> args, ChocolateyConfiguration config, IFileSystem fileSystem, IXmlService xmlService, Action<string> notifyWarnLoggingAction)
{
set_file_configuration(config, fileSystem, xmlService, notifyWarnLoggingAction);
ConfigurationOptions.reset_options();
set_global_options(args, config);
set_environment_options(config);
}
示例8: help_message
public virtual void help_message(ChocolateyConfiguration configuration)
{
this.Log().Info(ChocolateyLoggers.Important, "Pack Command");
this.Log().Info(@"
Chocolatey will attempt to package a nuspec into a compiled nupkg. Some
may prefer to use `cpack` as a shortcut for `choco pack`.
NOTE: 100% compatible with older chocolatey client (0.9.8.32 and below)
with options and switches. In most cases you can still pass options
and switches with one dash (`-`). For more details, see
the command reference (`choco -?`).
NOTE: `cpack` has been deprecated as it has a name collision with CMake. Please
use `choco pack` instead. The shortcut will be removed in v1.
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
choco pack [<path to nuspec>] [<options/switches>]
cpack [<path to nuspec>] [<options/switches>] (DEPRECATED)
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
"chocolatey".Log().Info(@"
choco pack
choco pack --version 1.2.3
choco pack path/to/nuspec
choco pack --outputdirectory build
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches");
}
示例9: configure_argument_parser
public void configure_argument_parser(OptionSet optionSet, ChocolateyConfiguration configuration)
{
optionSet
.Add("s=|source=",
"Source - Source location for install. Can include special 'webpi'. Defaults to sources.",
option => configuration.Sources = option.remove_surrounding_quotes())
.Add("l|lo|localonly|local-only",
"LocalOnly - Only search against local machine items.",
option => configuration.ListCommand.LocalOnly = option != null)
.Add("pre|prerelease",
"Prerelease - Include Prereleases? Defaults to false.",
option => configuration.Prerelease = option != null)
.Add("i|includeprograms|include-programs",
"IncludePrograms - Used in conjunction with LocalOnly, filters out apps chocolatey has listed as packages and includes those in the list. Defaults to false.",
option => configuration.ListCommand.IncludeRegistryPrograms = option != null)
.Add("a|all|allversions|all-versions",
"AllVersions - include results from all versions.",
option => configuration.AllVersions = option != null)
.Add("u=|user=",
"User - used with authenticated feeds. Defaults to empty.",
option => configuration.SourceCommand.Username = option.remove_surrounding_quotes())
.Add("p=|password=",
"Password - the user's password to the source. Defaults to empty.",
option => configuration.SourceCommand.Password = option.remove_surrounding_quotes())
;
//todo exact name
}
示例10: handle_validation
public void handle_validation(ChocolateyConfiguration configuration)
{
if (configuration.FeatureCommand.Command != FeatureCommandType.list && string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name))
{
throw new ApplicationException("When specifying the subcommand '{0}', you must also specify --name.".format_with(configuration.FeatureCommand.Command.to_string()));
}
}
示例11: configure_argument_parser
public void configure_argument_parser(OptionSet optionSet, ChocolateyConfiguration configuration)
{
optionSet
.Add("s=|source=",
"Source - The source to find the package(s) to install. Special sources include: ruby, webpi, cygwin, windowsfeatures, and python. Defaults to default feeds.",
option => configuration.Sources = option)
.Add("version=",
"Version - A specific version to uninstall. Defaults to unspecified.",
option => configuration.Version = option.remove_surrounding_quotes())
.Add("a|allversions|all-versions",
"AllVersions - Uninstall all versions? Defaults to false.",
option => configuration.AllVersions = option != null)
.Add("ua=|uninstallargs=|uninstallarguments=|uninstall-arguments=",
"UninstallArguments - Uninstall Arguments to pass to the native installer in the package. Defaults to unspecified.",
option => configuration.InstallArguments = option.remove_surrounding_quotes())
.Add("o|override|overrideargs|overridearguments|override-arguments",
"OverrideArguments - Should uninstall arguments be used exclusively without appending to current package passed arguments? Defaults to false.",
option => configuration.OverrideArguments = option != null)
.Add("notsilent|not-silent",
"NotSilent - Do not uninstall this silently. Defaults to false.",
option => configuration.NotSilent = option != null)
.Add("params=|parameters=|pkgparameters=|packageparameters=|package-parameters=",
"PackageParameters - Parameters to pass to the package. Defaults to unspecified.",
option => configuration.PackageParameters = option.remove_surrounding_quotes())
.Add("x|forcedependencies|force-dependencies|removedependencies|remove-dependencies",
"RemoveDependencies - Uninstall dependencies when uninstalling package(s). Defaults to false.",
option => configuration.ForceDependencies = option != null)
.Add("n|skippowershell|skip-powershell",
"Skip Powershell - Do not run chocolateyUninstall.ps1. Defaults to false.",
option => configuration.SkipPackageInstallProvider = option != null)
;
}
示例12: handle_validation
public void handle_validation(ChocolateyConfiguration configuration)
{
if (string.IsNullOrWhiteSpace(configuration.PackageNames))
{
throw new ApplicationException("Package name is required. Please pass at least one package name to uninstall.");
}
}
示例13: PoshHost
public PoshHost(ChocolateyConfiguration configuration)
{
ExitCode = -1;
_configuration = configuration;
_psUI = new PoshHostUserInterface(configuration);
_version = get_current_version();
}
示例14: configure_argument_parser
public void configure_argument_parser(OptionSet optionSet, ChocolateyConfiguration configuration)
{
optionSet
.Add("a|auto|automaticpackage",
"AutomaticPackage - Generate automatic package instead of normal. Defaults to false",
option => configuration.NewCommand.AutomaticPackage = option != null)
.Add("t=|template=|template-name=",
"TemplateName - Use a named template in {0}\\templates\\templatename instead of built-in template.".format_with(ApplicationParameters.InstallLocation),
option => configuration.NewCommand.TemplateName = option)
.Add("name=",
"Name [Required]- the name of the package. Can be passed as first parameter without \"--name=\".",
option =>
{
configuration.NewCommand.Name = option.remove_surrounding_quotes();
configuration.NewCommand.TemplateProperties.Add(TemplateValues.NamePropertyName, option.remove_surrounding_quotes());
})
.Add("version=",
"Version - the version of the package. Can also be passed as the property PackageVersion=somevalue",
option => configuration.NewCommand.TemplateProperties.Add(TemplateValues.VersionPropertyName, option.remove_surrounding_quotes()))
.Add("maintainer=",
"Maintainer - the name of the maintainer. Can also be passed as the property MaintainerName=somevalue",
option => configuration.NewCommand.TemplateProperties.Add(TemplateValues.MaintainerPropertyName, option.remove_surrounding_quotes()))
;
//todo: more built-in templates
}
示例15: help_message
public virtual void help_message(ChocolateyConfiguration configuration)
{
this.Log().Info(ChocolateyLoggers.Important, "Pack Command");
this.Log().Info(@"
Chocolatey will attempt to package a nuspec into a compiled nupkg. Some
may prefer to use `cpack` as a shortcut for `choco pack`.
NOTE: `cpack` has been deprecated as it has a name collision with CMake. Please
use `choco pack` instead. The shortcut will be removed in v1.
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
choco pack [<path to nuspec>] [<options/switches>]
cpack [<path to nuspec>] [<options/switches>] (DEPRECATED)
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
"chocolatey".Log().Info(@"
choco pack
choco pack --version 1.2.3
choco pack path/to/nuspec
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches");
}