Code Monkey home page Code Monkey logo

chocoman's People

Contributors

daileng avatar regg00 avatar we-mi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

corbob we-mi daileng

chocoman's Issues

Implement "WhatIf"-Parameter

Is your feature request related to a problem? Please describe.
For testing purposes or just to see what would happen, there should be a "WhatIf"-Parameter.

Describe the solution you'd like
When I'm not sure if my command breaks something I usually test the command with an WhatIf parameter, like:

Get-ChocoPackage | Uninstall-ChocoPackage -Verbose -WhatIf

choco.exe supports this feature when passing one of these

--noop, --whatif, --what-if
     NoOp / WhatIf - Don't actually do anything.

Describe alternatives you've considered
There is no real alternative. You could use "-Verbose" and "-Debug" but you can't call choco.exe without specifying --noop because this would actually execute your command.

Additional context
This can be implemented like "Force" or "AskForConfirmation"

Better way to parse choco command outputs

Is your feature request related to a problem? Please describe.
Not a problem, but a significant improvement.
The way choco outputs are parsed right now is too basic.

Describe the solution you'd like
The matching should be done more specifically using regex queries with the Select-String command.

Describe alternatives you've considered
$CommandOutput.RawOutput -like "*$n *already installed.*"

Additional context
Given the following output:

Installing the following packages:
    rufus
    By installing, you accept licenses for the packages.

    rufus v4.2.0 [Approved]
    rufus package files install completed. Performing other installation steps.
     ShimGen has successfully created a shim for rufus.exe
     The install of rufus was successful.
      Software installed to 'C:\ProgramData\chocolatey\lib\rufus'

    Chocolatey installed 1/1 packages.
     See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

We can extract the Name, Version and Status with those commands:

$Name = ($test | Select-String '^rufus$').matches[0].value
$Version = ($test | Select-String 'v\d.\d.\d').matches[0].value
$Installed = $test | Select-String '^ The install of rufus was successful.$' -Quiet

Create a Upgrade-ChocoPackage function

Is your feature request related to a problem? Please describe.
Not a problem, but the Upgrade-ChocoPackage function could be useful sometimes especially if it supports pipeline input.

Describe the solution you'd like
Create a new function called Upgrade-ChocoPackage that supports pipeline input.

Describe alternatives you've considered
There's already a -Upgrade switch for Install-ChocoPackage but it's easier to have a dedicated function.

Get-ChocoOutdated: Cannot Validate Argument on Parameter 'InputObject' When No Packages are Outdated

Describe the bug
The Get-ChocoOutdated cmdlet will generate an error stating "Cannot validate argument on parameter 'InputObject'. The argument is null. Provide a valid value for the argument, and then try running the command again." when Chocolatey has no packages available to update. It specifically mentions the error occurring on line 44 at the (Invoke-ChocoCommand -Arguments $Arguments).RawOutput syntax.

To Reproduce
Steps to reproduce the behavior:

  1. Run PowerShell.
  2. Use chocolatey to bring all packages up to date.
  3. Run Get-ChocoOutdated and observe the Null exception.
  4. Run the choco outdated -r -no-color command directly and observe the empty output returned.

Expected behavior
Get-ChocoOutdated should simply return $null when no packages are outdated.

Screenshots
If applicable, add screenshots to help explain your problem.

image

Get Package Details

Is your feature request related to a problem? Please describe.
Not related to a problem per se, just an enhancement

Describe the solution you'd like
I'd like to be able to fetch details about a package. Mainly interested in tags (i.e. I might want to exclude showing admin utilities or prerequisite/runtimes by default, or only show packages applicable for a particular dept). This might not be a broadly used feature, but something I've needed several times.

Line by line, the value output is inconsistent. Some lines contain multiple data/value pairs (i.e. Publish date is output on the same line as the package title). Aside from splitting out the data to a custom PS Object, the only other consideration I think is the fact that you can fetch details from locally installed packages AND repositories. I can see one of two solutions, adding -Details parameter to Search-ChocoPackage and Get-ChocoPackage or a standalone command Get-ChocoPackageDetails and specifying a parameter to designate where to get the details from.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Attached sample output

image

Calling some functions without admin-rights leads to unpredictable behaviour

Describe the bug
Some actions of choco.exe needs admin-privileges to function normally.
If you do not have them you get a warning and can choose to continue anyway. The dialog times out after 20 seconds and defaults to 'N' (Not proceed).
The output of some ChocoMan-functions are unpredicatable, because the output cannot be parsed, so in the end you don't know if the commands were executed properly or not.

To Reproduce
Steps to reproduce the behavior:

  1. Start powershell without administrator privileges
  2. Execute Install-ChocoPackage -Name openscad
  3. Wait at least 20 seconds
  4. See output from function, like:
> Install-ChocoPackage "openscad"
Name     Status Version
----     ------ -------
openscad

Expected behavior
The affected ChocoMan-Functions should give a warning that they are not started with the needed priviliges.

Additional context
The output from the commands are different. It depends on what function is used and if the package is already installed or not.

One could use choco.exe without admin-privileges but this does not work for every package.

choco.exe checks if the Tag admin is present for the package and gives the above warning.
If the Tag is not present it just continues with the package installation/uninstallation/upgrade, but it depends on the package if this succeeds (maybe installing software in the users home directory)

This is also applicable for changing sources.

The above warning can not be seen when calling choco.exe with Invoke-ChocoCmd because it redirects all output to a variable.
You can only see it when calling choco.exe directly.

The warning is:

Chocolatey detected you are not running from an elevated command shell
 (cmd/powershell).

 You may experience errors - many functions/packages
 require admin rights. Only advanced users should run choco w/out an
 elevated shell. When you open the command shell, you should ensure
 that you do so with "Run as Administrator" selected. If you are
 attempting to use Chocolatey in a non-administrator setting, you
 must select a different location other than the default install
 location. See
 https://docs.chocolatey.org/en-us/choco/setup#non-administrative-install
 for details.

For the question below, you have 20 seconds to make a selection.

 Do you want to continue?([Y]es/[N]o):

Improve upgrade command status

Is your feature request related to a problem? Please describe.
Not a problem, but right now, when running Install-ChocoPackage with the -Upgrade switch, if the package is already up to date, then the message is not clear enough.

Describe the solution you'd like
Return a status message stating that the package is already on the latest version.

Additional context
Here's an example of an upgrade request on an already upgraded package.

PS C:\Users\regg0> install-ChocoPackage -Name winscp -Upgrade -Verbose
VERBOSE: Chocolatey is installed.
VERBOSE: Chocolatey is installed.
VERBOSE: Command to execute: choco upgrade -y winscp --source chocolatey -r --no-color
VERBOSE: Chocolatey is installed.
VERBOSE: Chocolatey is installed.
VERBOSE: Command to execute: choco list -r --no-color

Name   Status Version
----   ------ -------
winscp        6.1.1

Show progress on installation

Is your feature request related to a problem? Please describe.
Show some kind of progress on the installation of packages.

Describe the solution you'd like
Using Write-Progress, write the installation progress to the screen. Also, add a parameter to hide the progress. Refer to ProgressPreference.

Describe alternatives you've considered
Just showing the choco command output would do the trick, but it's not the PowerShell way.

Include Support for -Pre parameter

Is your feature request related to a problem? Please describe.
Rarely comes up but today I happened to need to get list of apps that had pre-releases available and realized there wasn't support for -Pre parameter.

Describe the solution you'd like
Support for passing off -Pre parameter specifically or perhaps an "overflow" parameter that will tag a string on the end of the choco command arguments so almost any parameter can be supported

I can add -Pre or an "Additional Arguments" overflow if you'd like to tell me your preference

Enable piping of objects

First things first: This is module is great ๐Ÿ‘

I wanted to write my own powershell module for using choco, but I don't need that, because this is (almost, hence this issue) exactly how I want to use choco from within powershell.

Is your feature request related to a problem? Please describe.
Not really a problem. More like "using the full potential of powershell"-comfort-feature

Describe the solution you'd like

What you typically use pipelines for is something like this:

Get-Something | Filter-Something | Do-Something

What I want to use is something like that (I'll keep it simple, but you will get the point):

# I know that "Uninstall-ChocoPackage" is not implemented yet
Get-ChocoPackage | Where-Object { $_.Name -like "*vlc*" } | Uninstall-ChocoPackage

Describe alternatives you've considered

There is no alternative for the almighty powershell-pipeline :D

OK, jokes aside. There's always another way (same result as example above):

Get-ChocoPackage | Where-Object { $_.Name -like "*vlc*" } | ForEach-Object { Uninstall-ChocoPackage -Name $_ }

or

$packages = Get-ChocoPackage | Where-Object { $_.Name -like "*vlc*" }
foreach($package in $packages) {
    Uninstall-ChocoPackage -Name $package
}

But i find the pipeline-approach of the cmdlets much more readable

Additional context
Please let me know if I can assist in any way by implementing this feature

Implement passing multiple package names at once

Is your feature request related to a problem? Please describe.
Not a real problem. Just for convenience :)

Describe the solution you'd like
I want to pass an array of strings to Uninstall-ChocoPackage, Install-ChocoPackage, and other functions where this sort of feature makes sense.

It is currently not possible to do

Install-ChocoPackage -Name "firefox","vlc"

Describe alternatives you've considered
One could do this

Install-ChocoPackage -Name "firefox"
Install-ChocoPackage -Name "vlc"

Additional context
I think this makes sense for a lot of functions in order to support a wider range of use-cases.
For example:
Get-ChocoPackage could use this to list more than one but not all packages

I'll create a PR for Uninstall-ChocoPackage and Install-ChocoPackage later

No Authorization header detected message

Describe the bug
In some cases, chocolatey returns the following message [NuGet] No Authorization header detected. That message is getting parsed as a chocolatey package and is displayed by the Get-ChocoOutdated for example.

To Reproduce
Steps to reproduce the behavior:

  1. Run Get-ChocoOutdated
  2. Check output
Name                                     CurrentVersion AvailableVersion Pinned
----                                     -------------- ---------------- ------
[NuGet] No Authorization header detected
adobereader                              2023.3.20201.1 2023.3.20244     false

Expected behavior
Only a list of packages should be returned.

Screenshots
image

Desktop:

  • OS: Windows 11
  • Browser: Edge
  • Chocolatey Version: 2.1.0
  • ChocoMan Version: 0.12.0

Install-ChocoPackage: Name Parameter Supports String[] Value but does not Pass it to Choco

Describe the bug
The Install-ChocoPackage Name parameter does support an array of package names being passed to it however it does not appear to invoke Chocolatey to install multiple packages. So if you run the following:

$PackageList = @("conemu", "pwsh", "powertoys")
Install-ChocoPackage -Name $PackageList

Only the first entry in the array (In this case ConEmu) will get installed. You can workaround the issue by using:

ForEach ($PackageName In $PackageList) { Install-ChocoPackage -Name $PackageName }

However, that invokes Chocolatey each time.

To Reproduce
Steps to reproduce the behavior:

  1. Define a string array with a list of Chocolatey package names such as $PackageList = @("conemu", "pwsh", "powertoys")
  2. Pass the string array to the Name parameter for Install-ChocoPackage such as Install-ChocoPackage -Name $PackageList
  3. Observe that only one package is installed in the output.
  4. Call Get-ChocoPackage and observe that the two other packages in $PackageList are missing from the output.

Expected behavior
Passing a string[] value to the -Name parameter should install multiple packages defined in the array value.

Desktop (please complete the following information):

  • OS: Windows 11 (23H2)
  • ChocoMan Version: 1.2.3
  • PowerShell Version: 5.1 and 7.4.0

Additional context
Chocolatey does support passing a string array value to it directly as I've used this in the past on a virtual machine template to install multiple packages at the same time. The command to use is as simple as doing the following:

$PackageList = @("conemu", "powertoys", "pwsh", "notepadplusplus")
choco install $PackageList -y

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.