diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli.rb | 5 | ||||
-rw-r--r-- | lib/bundler/cli/list.rb | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3cefc90970..3406a874ce 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -263,10 +263,11 @@ module Bundler # TODO: 2.0 remove `bundle show` if Bundler.feature_flag.list_command? - desc "list", "list all gems in the bundle" + desc "list", "List all gems in the bundle" + method_option "name-only", :type => :boolean, :banner => "print only the gem names" def list require "bundler/cli/list" - List.new.run + List.new(options).run end map %w[ls] => "list" diff --git a/lib/bundler/cli/list.rb b/lib/bundler/cli/list.rb index 623e2bc076..b5e7c1e650 100644 --- a/lib/bundler/cli/list.rb +++ b/lib/bundler/cli/list.rb @@ -2,12 +2,17 @@ module Bundler class CLI::List + def initialize(options) + @options = options + end + def run - specs = Bundler.load.specs.reject {|s| s.name == "bundler" } + specs = Bundler.load.specs.reject {|s| s.name == "bundler" }.sort_by(&:name) + return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"] return Bundler.ui.info "No gems in the Gemfile" if specs.empty? Bundler.ui.info "Gems included by the bundle:" - specs.sort_by(&:name).each do |s| + specs.each do |s| Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})" end |