Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to remove sources without knowing their names #1493

Open
ghost opened this issue Feb 13, 2018 · 12 comments
Open

A way to remove sources without knowing their names #1493

ghost opened this issue Feb 13, 2018 · 12 comments

Comments

@ghost
Copy link

ghost commented Feb 13, 2018

It would be nice if there was a direct way to remove sources we don't know the name of (something like, choco source remove all).

Example use case: You need to use a script to move a machine from one environment to the other, and you need to disable package sources associated with the old environment, without your script necessarily knowing what the original environment was. Simply removing all configured sources before adding the new ones is the ideal way to go.

@ferventcoder
Copy link
Member

@joshuathornton862 thanks for adding that. I wanted to link where the original conversation took place, was that on gitter?

@ghost
Copy link
Author

ghost commented Feb 20, 2018 via email

@ferventcoder
Copy link
Member

@renehernandez
Copy link

@ferventcoder I want to give a try to implement this. I am a new contributor to this repo. Any suggestions?

@gep13
Copy link
Member

gep13 commented May 31, 2019

@renehernandez if I may make a suggestion...

On my stream I have recently been working on adding a new Export Command for Chocolatey, which walks through the process of getting started with the Chocolatey code base. This started on this stream here:

https://github.com/gep13-oss/live-streams/blob/master/README.md

And continued here:

https://github.com/gep13-oss/live-streams/blob/master/README.md

And in this stream, @ferventcoder and I went through a PR review of what was created:

https://github.com/gep13-oss/live-streams/blob/master/README.md

These could be a good place to get started.

Let me know if you have any questions.

@renehernandez
Copy link

I have already drafted the implementation for this. What is preferred for this feature:

  • choco source remove all or
  • choco source remove -n=all

renehernandez pushed a commit to renehernandez/choco that referenced this issue Jun 25, 2019
@renehernandez
Copy link

@gep13 Also, I couldn't find a good example of how to test source removal in the solution. Any suggestions there?

@renehernandez
Copy link

@ferventcoder @gep13 Any suggestions to my previous comments?

@magnani1
Copy link

Put in .bat or .cmd:

SET "choco=%systemdrive%\ProgramData\chocolatey\choco.exe"
for /f "tokens=1" %%i in ('%choco% source list') do %choco% source remove -name %%i

@magnani1
Copy link

It would be nice if there was a direct way to remove sources we don't know the name of (something like, choco source remove all).

Example use case: You need to use a script to move a machine from one environment to the other, and you need to disable package sources associated with the old environment, without your script necessarily knowing what the original environment was. Simply removing all configured sources before adding the new ones is the ideal way to go.

Put in .bat or .cmd:

SET "choco=%systemdrive%\ProgramData\chocolatey\choco.exe"
for /f "tokens=1" %%i in ('%choco% source list') do %choco% source remove -name %%i

@ferventcoder
Copy link
Member

this feel more appropriate - choco source remove all

@vexx32
Copy link
Member

vexx32 commented Apr 1, 2022

@corbob do you think this would be a good kind of test to include in the Pester tests you're currently working on, or would it be better to include in the C# unit tests for the source command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants