Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Default to printing a help message when bundle is run without arguments on 2.0 #5725

Merged
merged 1 commit into from Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/bundler/cli.rb
Expand Up @@ -55,7 +55,14 @@ def initialize(*args)
check_unknown_options!(:except => [:config, :exec])
stop_on_unknown_option! :exec

default_task :install
desc "cli_help", "Prints a summary of bundler commands", :hide => true
def cli_help
version
Bundler.ui.info "\n"
self.class.help(shell)
end
default_task(Bundler.feature_flag.default_cli_command)

class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
:desc => "Specify the number of times you wish to attempt network commands"
Expand Down
20 changes: 16 additions & 4 deletions lib/bundler/feature_flag.rb
Expand Up @@ -5,12 +5,24 @@ def self.settings_flag(flag, &default)
unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s)
raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key"
end
define_method("#{flag}?") do
value = Bundler.settings[flag]

settings_method("#{flag}?", flag, &default)
end
private_class_method :settings_flag

def self.settings_option(key, &default)
settings_method(key, key, &default)
end
private_class_method :settings_option

def self.settings_method(name, key, &default)
define_method(name) do
value = Bundler.settings[key]
value = instance_eval(&default) if value.nil? && !default.nil?
value
end
end
private_class_method :settings_method

(1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }

Expand All @@ -20,6 +32,8 @@ def self.settings_flag(flag, &default)
settings_flag(:error_on_stderr) { bundler_2_mode? }
settings_flag(:init_gems_rb) { bundler_2_mode? }

settings_option(:default_cli_command) { bundler_2_mode? ? :cli_help : :install }

def initialize(bundler_version)
@bundler_version = Gem::Version.create(bundler_version)
end
Expand All @@ -28,7 +42,5 @@ def major_version
@bundler_version.segments.first
end
private :major_version

class << self; private :settings_flag; end
end
end
1 change: 1 addition & 0 deletions spec/quality_spec.rb
Expand Up @@ -169,6 +169,7 @@ def check_for_specific_pronouns(filename)

it "documents all used settings" do
exemptions = %w[
default_cli_command
gem.coc
gem.mit
warned_version
Expand Down