Added batch mode to chocolatey.cmd - cinst multiple packages #304
Conversation
Anyway, I strongly encourage you to merge this (and port it to the monolith if you want, but merge it first). When you do this trick on a random strangers laptop, they become so happy, you get instant Chocolatey fans. But it won't work if they install Chocolatey on someone elses laptop. Until this is merged, that is. ;) |
ummm...I kindly disagree... - "but it should not be in there like today". cinst putty -Version 0.62.0.1 works before this change but not after. Relying on the count of params is not a satisfactory test for batch mode. plus I agree with @ferventcoder that if you're changing one ingress into calling chocolatey we should make it consistent. Forking the functionality between cmd and powershell functionality is not ideal since the cmd is really a convenience factor for non-posh access |
one last thing I might opt for array splat handling in posh or take the packages in via a pipeline, which means the source could be handled any way the user wants (objects) maybe like 7zip vlc putty | chocolatey install |
Nope, it works fine here. Single packages are handled exactly as before. I just installed putty to confirm your response but I had no problem. This is Windows 7 Home Premium with .NET 4.0.
And your pipe example is a totally bad unintuitive crazy kinda Chocolatey-will-never-get-popular-this-way language construct IMO. I just want to see this Chocolatey be more like... well, every other package manager out there in the Linux world so that you can actually guess how it works.
There I fixed it. You're welcome. ;) |
Are you running windows XP or an older .NET? Or did you make an accidental typo when trying my code? Because if it is the former that does not like the code, I can rewrite the batch in MS-DOS style. Uglier but maybe more compatible? (I'm just guessing here) I thought XP already did work with the 'new' syntax though. |
One last thing, I am not "Relying on the count of params". It just batches all params one by one. |
let me retest. I will use current choco version and report results... I do like the concept btw - i wasn't trying to be a pita. |
I removed my custom version an ran this- on a fresh Win7 Enterprise, I bootstrapped with the install method on http://chocolatey.org/ within cmd.exe:
|
@PowerShell -NoProfile -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' %*" | ||
set numArgs=0 | ||
for %%n in (%*) do Set /A numArgs+=1 | ||
if '%numArgs%' GTR '2' echo Installing packages in batch mode. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I just don't remember batch scripting, but it appears at first glance you are assuminganything GTR 2 parameters after cinst (aka install) are both package names. in that use case it works, and nicely I might add.
in the case of cinst putty -Version 0.62.0.1, this logic appears flawed based on my screen paste, since it is trying to batch install a package named "-version"
i am not using alpha version (which is the one on github iirc) |
Oh! I misunderstood you! You are correct. Let me get back to you when I am
|
You were absolutely right. When you said "cinst putty -Version 0.62.0.1 works before this change but not after." I thought you just mentioned the version of putty as a courtesy to me to be able to verify, instead of meaning an actual command. I should have picked up on the minus sign, but you can also use Having said that, I now remember why I didn't push this mod in the first place when I made it: Although I personally don't care about version management and just ignored it - I only use Chocolatey to batch install 30 apps on a clean system for others, and additional apps for myself although I rarely use Windows - I know I purposely ignored the rest of the commands and that is why I shouldn't push this. I just forgot about it after a long time. However, I do seriously mean that this feature is absolutely invaluable to the point that I'd rather create a custom installer for myself and everyone I recommend Chocolatey to, than wait 15 months for someone to port this to On a more positive note, I just fixed all the problems in my latest commit. :) You can now either install multiple packages, or give commands using -wildcards as specified in |
Single: C:\Users\Redsandro>cinst notepadplusplus
Chocolatey (v0.9.8.20) is installing notepadplusplus and dependencies. By installing you accept the license for notepadplusplus and each dependency you are installing.
______ notepadplusplus.install v6.3.3 ______
# blah blah Added commands (works with all commands): C:\Users\Redsandro>cinst notepadplusplus -version 2.24.1
Chocolatey (v0.9.8.20) is installing notepadplusplus and dependencies. By installing you accept the license for notepadplusplus and each dependency you are installing.
Unable to find version '2.24.1' of package 'notepadplusplus'.
# etc etc Batch mode: C:\Users\Redsandro>cinst notepadplusplus treesize
Installing packages in batch mode.
Installing notepadplusplus ...
Chocolatey (v0.9.8.20) is installing notepadplusplus and dependencies. By installing you accept the license for notepadplusplus and each dependency you are installing.
'notepadplusplus 6.3.3' already installed.
If you want to reinstall the current version of an existing package, please use the -force command.
Finished installing 'notepadplusplus' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.
Installing treesize ...
Chocolatey (v0.9.8.20) is installing treesize and dependencies. By installing you accept the license for treesize and each dependency you are installing.
Unable to find package 'treesize'.
Finished installing 'treesize' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.
Installed all packages. :) |
Iirc the chocolatey.ps1 isnt using positional parameters... so shouldnt I appreciate your efforts but I think trying to solve this via cmd will only make fixing it via ps1 needing to unwind this. Maybe others have an opinion on this... I love the idea btw. -------- Original message -------- Single: C:\Users\Redsandro>cinst notepadplusplus blah blahAdded commands (works with all commands): C:\Users\Redsandro>cinst notepadplusplus -version 2.24.1 etc etcBatch mode: C:\Users\Redsandro>cinst notepadplusplus treesize Installing notepadplusplus ... Chocolatey (v0.9.8.20) is installing notepadplusplus and dependencies. By installing you accept the license for notepadplusplus and each dependency you are installing. Finished installing 'notepadplusplus' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure. Installing treesize ... Chocolatey (v0.9.8.20) is installing treesize and dependencies. By installing you accept the license for treesize and each dependency you are installing. Finished installing 'treesize' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure. Installed all packages. :) — |
Does that work? As far as I know, I think this is pretty rock-solid. But in the end you can break everything if you want it to, especially this hideous thing called |
Also, don't underestimate the power of I do know the opinion of non-technical users. It has astounding similarities with the last sentence in the chorus of Thrift Shop by Macklemore. As a final exposition I would like to constrain how much added value this is to normal users. And we're all busy people, the smallest The reason that I am pushing this so vividly is that I had four people applaud enthousiasticly this Chocolatey trick I did, and when they mention they want to implement that in their own workflow, I have to explain that I'm using a custom version and they need to copy my blabla.cmd to yaddah yaddah (translated into how they perceive my instructions) and they are like: Wut? http://goo.gl/OdpNo |
I googled this thrift shop and watched http://vimeo.com/m/57418480 ... no words. Made my day |
Well, 15 months or a few days... still doesn't make it right c9f9e8d |
so this requires comma between package names. I am trying to figure out removing everything from implicitly being positional but running into a few issues I will need to explore later. |
Wow, it's handy to know powershell. :P Details are very important. Details can even make an overpriced turd popular. Just look at Apple Inc. That's why I'm seemingly nitpicky, but please understand it is only because I care. :) That said, this is a big step forward. But it's still unintuitive-ish. These days, smartphones come without a manual because everything is tackled in the simplest feasible decimation. People (can) rely on that. Not needing comma's is a smartphone that doesn't need a manual. Otherwise we'd have to explain in the manual: We know the 10 most popular package managers use space delimited package lists for batch installation, but we need a comma separated list because [insert reason the user doesn't really care about]. Especially if you promote Chocolatey as "like apt-get". I know, semantically "like" allows for variations. But that's not how the world, users from the three most popular distro's that use apt-get, and google, work. We can probably use both btw. Just putting it out there. |
Yep. Notice I said temporarily need a comma. On Thursday, June 27, 2013, Redsandro wrote:
Rob http://devlicio.us/blogs/rob_reynolds |
Temporarily? :P Comma is inherent to powershell array afaik so I'm not sure how you propose to do that, but that last comment makes me happy. :) |
its actually pretty easy - [parameter(Position=1, ValueFromRemainingArguments=$true)]
[string[]]$packageNames=@('') The hard part is that I have naming conflicts with debug and verbose. So I either have to change the names, which I'm not going to do, or drop powershell in favor of c# calling powershell packages (which is in the plans anyway). |
That simple huh. By c# replacing ps, do you mean you want to rewrite the entire monolith? |
I have it working now, but I had to remove the two naming conflicts... and those need to stay in. For reference: http://stackoverflow.com/questions/6870362/can-i-create-a-script-with-parameter-that-has-aliasdb-in-powershell and http://stackoverflow.com/questions/10536282/powershell-defining-the-verbose-switch-in-a-function |
And you ask the twitters and the twitters provide... :) Fixed in 6ca7ed1 |
I don't understand the consequences of removing something that needs to stay in, but this is a huge step in the usability of Chocolatey! I am happy. Although I didn't test anything (already got a working batcher in place ;)) so I don't know if those rismoney testcases will hold up. |
So once rismoney approves, I suggest uploading a new release as soon as possible. YESTERDAY! |
I didn't remove, I just moved them down... :) So those things are still there. |
cup chocolatey -pre and you have it... :) |
@Redsandro I don't have to approve. I am only here to critique, debase, and hassle people :) Seriously though - the best thing about open source projects, which this "issue" illustrates so well, is that you had an idea, submitted a PR demonstrating a prototype on how you thought it should work, it was reviewed by people who care about the project, and someone else rose up to implement in a way that fits within the bigger picture. Awesome work for an awesome feature. |
That and I've been mulling over this guy for awhile in how I would see it implemented. :) |
Also your sarcasm went a long way into me getting off of my duff and getting 'er done. 👍 With my new job you should see a much faster response time... |
Yes I approve with a smile on my face. :) |
Beauty of a prerelease. Those can go out all day and night so folks can play with them. And if they don't work, well it was a prerelase... ;) |
hmm, if sarcasm works.... the feature I could really use to help get my internal packages opensourced is- Right now all my packages are hardcoded to an internal url, and ideally there would be a way to Summary I want to be able to create packages that can be used universally, on the public - via mirrors or private feed. Embedding a url becomes problematic to maintain. Then a param called pkgsource could be also used to override the default url. This has nothing to do with the -source, source (but you know that already) |
yep... know what you are talking about @rismoney - will Mark Johnson's stuff not work for you? The offline installer piece? |
link? |
Not really understanding what you mean. I thought your auto-update packages did something like that. I don't really understand those either. :P But apart from that, aren't all package sources hardcoded? We would need to have a sources registry. In which case we might as well add the silent installer switches to a registry. And the installation code. And we wouldn't need packages anymore. Sorry I am probably misunderstanding this. :P |
example-
myorg.com doesn't help you at all, and I don't want to put myorg url on the interwebs. |
but I want to publish 100s of packages, for the world to consume, because chocolatey adoption would skyrocket, if people knew how to install/uninstall everything from Office to Exchange Server using just cinst. I just want to sanitize them. |
we can certainly take this elsewhere. there might even be an issue on this. |
I wrote this batch installer.
It's a small clever hack I wrote some time ago for myself. But now that I installed Chocolatey on a friend's computer, I realized how much I missed this invaluable feature, so I thought I'd put it in a pull request.
Everything remains the same, but you can now also do this:
..and go drink a cofffee. :)