FEATURE: cleanup command add --no and --yes to auto confirm [Yn] #280

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@szuecs
szuecs commented Feb 18, 2012

In order to use the gem utility within shell scripts it would be nice to have options --no and --yes for automatically confirm all questions asked by ask_* methods.
This patch adds --no and --yes for the cleanup command, which I want to use within shell scripts.

@zenspider
Contributor

What about yes | gem uninstall xyz ?

@szuecs
szuecs commented Feb 19, 2012

Mäh, yeah you are so right. I always forget `yes'.
--no case:
yes n | gem uninstall

@szuecs szuecs closed this Feb 19, 2012
@rbq
rbq commented Mar 16, 2012

Would love to see this in Rubygems anyway. Or at least a hint in gem help. Piping yes/no to a command is not exactly an intuitive way to do this. This could patch could even be extended to asking [Ynae] (yes/no/allways/never).

@whoisjake

yes n | gem cleanup does not work on on OS X:

    Neoterius:~ jake $ gem cleanup minitest
    Cleaning up installed gems...
    Attempting to uninstall minitest-3.3.0

    You have requested to uninstall the gem:
        minitest-3.3.0
    heroku-api-0.3.5 depends on [minitest (>= 0)]
    hoe-3.1.0 depends on [minitest (~> 3.3)]
    launchy-2.1.2 depends on [minitest (~> 3.3.0)]
    less-rails-2.2.3 depends on [minitest (>= 0)]
    mime-types-1.19 depends on [minitest (~> 3.1)]
    omniauth-facebook-1.4.1 depends on [minitest (>= 0)]
    If you remove this gems, one or more dependencies will not be met.
    Continue with Uninstall? [Yn]  n
    Unable to uninstall minitest-3.3.0:
        Gem::DependencyRemovalException: Uninstallation aborted due to dependent gem(s)
    Clean Up Complete

    Neoterius:~ jake $ yes n | gem cleanup minitest
    Cleaning up installed gems...
    Attempting to uninstall minitest-3.3.0
    Successfully uninstalled minitest-3.3.0
    Clean Up Complete

my environment:

    Neoterius:~ jake $ gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 1.8.11
      - RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-darwin11.3.0]
      - INSTALLATION DIRECTORY: /Users/jake/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1
      - RUBY EXECUTABLE: /Users/jake/.rbenv/versions/1.9.3-p125/bin/ruby
      - EXECUTABLE DIRECTORY: /Users/jake/.rbenv/versions/1.9.3-p125/bin
      - RUBYGEMS PLATFORMS:
        - ruby
        - x86_64-darwin-11
      - GEM PATHS:
         - /Users/jake/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1
         - /Users/jake/.gem/ruby/1.9.1
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :benchmark => false
         - :backtrace => false
         - :bulk_threshold => 1000
         - "install" => "--no-rdoc --no-ri"
         - "update" => "--no-rdoc --no-ri"
      - REMOTE SOURCES:
         - http://rubygems.org/
@zenspider
Contributor

Confirmed. Also able to repro with gem uninstall minitest < /dev/null. I'm guessing this is due to our tty checks in user_interaction.rb.

@ScotterC ScotterC referenced this pull request in rubber/rubber May 8, 2013
Closed

Ruby 2.0 install, ri/rdoc prompt #354

@shadowbq

yes pipe does not work in powershell or in windows cmd environments..

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