summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-04-15 01:15:58 +0000
committerThe Bundler Bot <bot@bundler.io>2017-04-15 01:15:58 +0000
commit7ce45d7702479542975a98762cc33982d8fb6ee7 (patch)
treefd98f2bc089eab2a65dd89ad9d431f1d185d3b8a /lib
parent3b62843d99648b803c0210a09b54db36dbf5e1ab (diff)
parent3c52af901fb41b5d82a53ec5300e53b700404d50 (diff)
downloadbundler-7ce45d7702479542975a98762cc33982d8fb6ee7.tar.gz
Auto merge of #5306 - colby-swandale:bundler-config-parseable-flag, r=segiddins
Bundler config parseable flag This PR is continuing on from #4919. This adds an option to `bundle config` called `parseable` that prints the value of config without the verbose. Example: $ bundle config foo --parseable bar Closes #4919
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb1
-rw-r--r--lib/bundler/cli/config.rb30
2 files changed, 25 insertions, 6 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 9c49858e00..ba329b78cb 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -373,6 +373,7 @@ module Bundler
will show the current value, as well as any superceded values and
where they were specified.
D
+ method_option "parseable", :type => :boolean, :banner => "Use minimal formatting for more parseable output"
def config(*args)
require "bundler/cli/config"
Config.new(options, args, self).run
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
index 32724f687d..e8f13620ec 100644
--- a/lib/bundler/cli/config.rb
+++ b/lib/bundler/cli/config.rb
@@ -33,6 +33,13 @@ module Bundler
end
if args.empty?
+ if options[:parseable]
+ if value = Bundler.settings[name]
+ Bundler.ui.info("#{name}=#{value}")
+ end
+ return
+ end
+
confirm(name)
return
end
@@ -44,11 +51,20 @@ module Bundler
private
def confirm_all
- Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
- Bundler.settings.all.each do |setting|
- Bundler.ui.confirm "#{setting}"
- show_pretty_values_for(setting)
- Bundler.ui.confirm ""
+ if @options[:parseable]
+ thor.with_padding do
+ Bundler.settings.all.each do |setting|
+ val = Bundler.settings[setting]
+ Bundler.ui.info "#{setting}=#{val}"
+ end
+ end
+ else
+ Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
+ Bundler.settings.all.each do |setting|
+ Bundler.ui.confirm "#{setting}"
+ show_pretty_values_for(setting)
+ Bundler.ui.confirm ""
+ end
end
end
@@ -68,7 +84,9 @@ module Bundler
def message
locations = Bundler.settings.locations(name)
- if scope == "global"
+ if @options[:parseable]
+ "#{name}=#{new_value}" if new_value
+ elsif scope == "global"
if locations[:local]
"Your application has set #{name} to #{locations[:local].inspect}. " \
"This will override the global value you are currently setting"