choco config add
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
There should be a `choco config add` command. as `choco config set` will overwrite anything currently set.
example `choco config add ugradeAllExceptions `
for example, currently, you have no way to add an exception to upgradeAllExceptions without manually reading `choco get ugradeAllExceptions --limitoutput` and then splitting checking for existing packages, re-joining them and then setting.
Additionally, this is also true for removing items from a config.
I ended up writing the following to gain the ability to add and remove packages for upgradeAllExceptions. But it could be adapted for any config that is comma separated.
```
function Add-ChocoUpgradeAllException($package) {
$packages = (choco config get upgradeAllExceptions --limitoutput).Trim()
$packages = $packages -split ","
$packages = $packages | where {$_}
if ($packages -notcontains $package) {
[string[]]$packages += $package
Write-Host Adding $package to upgradeAllExceptions
Write-Host Setting upgradeAllExceptions to: $($packages -join ",") -f Yellow
choco config set upgradeAllExceptions $($packages -join ",")
}
else {
Write-Host "$package already set in upgradeAllExceptions"
}
Write-Host "`nupgradeAllExceptions:"
choco config get upgradeAllExceptions --limitoutput | Out-Host
}
function Remove-ChocoUpgradeAllException($package) {
$packages = (choco config get upgradeAllExceptions --limitoutput).Trim()
$packages = $packages -split ","
$packages = $packages | where {$_}
if ($packages -contains $package) {
$packages = $packages | Where-Object { $_ -ne $package }
Write-Host Removing $package from upgradeAllExceptions
Write-Host Setting upgradeAllExceptions to: $($packages -join ",") -f Yellow
if ($packages) {
choco config set upgradeAllExceptions $($packages -join ",")
}
else {
choco config unset upgradeAllExceptions
}
}
else {
Write-Host "$package not set in upgradeAllExceptions"
}
Write-Host "`nupgradeAllExceptions:"
choco config get upgradeAllExceptions --limitoutput | Out-Host
}
```
Such functionality should be given to choco natively.
Contributor guide
Research direction
Start by locating the existing `choco config set`, `get`, and `unset` command handlers. Define how `config add` and removal should handle comma-separated values such as `upgradeAllExceptions`, including duplicates and an empty result. Done means the native commands support adding and removing entries without manually reading and rewriting the setting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100