Skip to content

Commit

Permalink
(chocolatey#3565) Deprecate ListCommand.ExplicitSource
Browse files Browse the repository at this point in the history
Since we've added an ExplicitSources property to the top-level
configuration object, we do not need the ListCommand.ExplicitSource
property. It is being deprecated here to be removed in version 3. To
determine if an explicit source was provided, we can look at if
ExplicitSources is set.
  • Loading branch information
corbob committed Nov 25, 2024
1 parent 0f9e5ad commit 667fbc7
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public override void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConf
.Add(
"s=|source=",
"Source - Source location for install. Can use special 'windowsfeatures', 'ruby', 'cygwin', or 'python' sources. Defaults to configured sources.",
option => {
configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe();
configuration.ListCommand.ExplicitSource = true;
})
option => configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe())
.Add(
"l|lo|localonly|local-only",
"LocalOnly - Only search against local machine items.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi
optionSet
.Add("s=|source=",
"Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.",
option =>
{
configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe();
configuration.ListCommand.ExplicitSource = true;
})
option => configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe())
.Add("version=",
"Version - A specific version to install. Defaults to unspecified.",
option => configuration.Version = option.UnquoteSafe())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public virtual void Run(ChocolateyConfiguration config)
{
// Would have liked to have done this in the Validate method, but can't, since the SourceType
// hasn't yet been set, since the sources have not yet been parsed.
if (config.ListCommand.ExplicitSource && config.SourceType == SourceTypes.Normal)
if (!string.IsNullOrWhiteSpace(config.ExplicitSources) && config.SourceType == SourceTypes.Normal)
{
throw new ApplicationException("When using the '--source' option with the 'choco list' command, only a named alternative source can be provided.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi
optionSet
.Add("s=|source=",
"Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.",
option =>
{
configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe();
configuration.ListCommand.ExplicitSource = true;
})
option => configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe())
.Add("u=|user=",
"User - used with authenticated feeds. Defaults to empty.",
option => configuration.SourceCommand.Username = option.UnquoteSafe())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi
optionSet
.Add("s=|source=",
"Source - Source location for install. Can use special 'windowsfeatures', 'ruby', 'cygwin', or 'python' sources. Defaults to sources.",
option =>
{
configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe();
configuration.ListCommand.ExplicitSource = true;
})
option => configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe())
.Add("idonly|id-only",
"Id Only - Only return Package Ids in the list results.",
option => configuration.ListCommand.IdOnly = option != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi
optionSet
.Add("s=|source=",
"Source - The source to find the package(s) to install. Special sources include: ruby, cygwin, windowsfeatures, and python. To specify more than one source, pass it with a semi-colon separating the values (e.g. \"'source1;source2'\"). Defaults to default feeds.",
option =>
{
configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe();
configuration.ListCommand.ExplicitSource = true;
})
option => configuration.Sources = configuration.ExplicitSources = option.UnquoteSafe())
.Add("version=",
"Version - A specific version to install. Defaults to unspecified.",
option => configuration.Version = option.UnquoteSafe())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ public ListCommandConfiguration()
public bool NotBroken { get; set; }
public bool IncludeVersionOverrides { get; set; }
public bool ExplicitPageSize { get; set; }
[Obsolete("This property is deprecated and will be removed in v3. Check if the top-level ExplicitSources property is set instead.")]
public bool ExplicitSource { get; set; }
}

Expand Down

0 comments on commit 667fbc7

Please sign in to comment.