lib/github_cli/vendor/thor.rb in github_cli-0.5.9 vs lib/github_cli/vendor/thor.rb in github_cli-0.6.0

- old
+ new

@@ -1,10 +1,20 @@ require 'set' require 'thor/base' class Thor class << self + # Allows for custom "Command" package naming. + # + # === Parameters + # name<String> + # options<Hash> + # + def package_name(name, options={}) + @package_name = name.nil? || name == '' ? nil : name + end + # Sets the default command when thor is executed without an explicit command to be called. # # ==== Parameters # meth<Symbol>:: name of the default command # @@ -183,11 +193,16 @@ Thor::Util.thor_classes_in(self).each do |klass| list += klass.printable_commands(false) end list.sort!{ |a,b| a[0] <=> b[0] } - shell.say "Commands:" + if @package_name + shell.say "#{@package_name} commands:" + else + shell.say "Commands:" + end + shell.print_table(list, :indent => 2, :truncate => true) shell.say class_options_help(shell) end @@ -297,10 +312,10 @@ @stop_on_unknown_option ||= Set.new @stop_on_unknown_option.merge(command_names) end def stop_on_unknown_option?(command) #:nodoc: - !!@stop_on_unknown_option && @stop_on_unknown_option.include?(command.name.to_sym) + command && !@stop_on_unknown_option.nil? && @stop_on_unknown_option.include?(command.name.to_sym) end protected # The method responsible for dispatching given the args.