commander 4.4.6 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/History.rdoc +4 -0
 - data/commander.gemspec +1 -1
 - data/lib/commander/core_ext/array.rb +1 -1
 - data/lib/commander/help_formatters/terminal/command_help.erb +6 -6
 - data/lib/commander/help_formatters/terminal/help.erb +7 -7
 - data/lib/commander/methods.rb +2 -2
 - data/lib/commander/runner.rb +1 -1
 - data/lib/commander/user_interaction.rb +9 -9
 - data/lib/commander/version.rb +1 -1
 - data/spec/methods_spec.rb +3 -3
 - data/spec/spec_helper.rb +1 -1
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9bb88c28e0d43c3616cceb161661a306fbcb74ef6c68ce67bc5aee8e820498cd
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9c5295c278179f4325c179b61a07182c45f3ed911b8228294cdf53e83cb6fe74
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 977685b95002c9e0dcaafd60da783473dc1e2d90f72eec6c1fc209d7ba6ff498f7941f2ac263244775d58d5f41b7bda7e57d7a39041963d8ec85852c20b99ee9
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2c2eb1a834b1446b61d0ac7dbeb8f0575f80ab10e57d432a6710c4e37eb24eb870a6312655be5f27f3d4250505320f04fb46c763f91ef688b9e6c96fa573b45e
         
     | 
    
        data/History.rdoc
    CHANGED
    
    
    
        data/commander.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              s.executables   = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
         
     | 
| 
       19 
19 
     | 
    
         
             
              s.require_paths = ['lib']
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              s.add_runtime_dependency('highline', '~>  
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_runtime_dependency('highline', '~> 2.0.0')
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              s.add_development_dependency('rspec', '~> 3.2')
         
     | 
| 
       24 
24 
     | 
    
         
             
              s.add_development_dependency('rake')
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Array
         
     | 
| 
       2 
2 
     | 
    
         
             
              ##
         
     | 
| 
       3 
3 
     | 
    
         
             
              # Split _string_ into an array. Used in
         
     | 
| 
       4 
     | 
    
         
            -
              # conjunction with  
     | 
| 
      
 4 
     | 
    
         
            +
              # conjunction with HighLine's #ask, or #ask_for_array
         
     | 
| 
       5 
5 
     | 
    
         
             
              # methods, which must respond to #parse.
         
     | 
| 
       6 
6 
     | 
    
         
             
              #
         
     | 
| 
       7 
7 
     | 
    
         
             
              # This method allows escaping of whitespace. For example
         
     | 
| 
         @@ -1,22 +1,22 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
     | 
    
         
            -
              <%=  
     | 
| 
      
 2 
     | 
    
         
            +
              <%= HighLine.default_instance.color "NAME", :bold %>:
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
                <%= @name %>
         
     | 
| 
       5 
5 
     | 
    
         
             
            <% if @syntax -%>
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
              <%=  
     | 
| 
      
 7 
     | 
    
         
            +
              <%= HighLine.default_instance.color "SYNOPSIS", :bold %>:
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                <%= @syntax -%>
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            <% end -%>
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
              <%=  
     | 
| 
      
 13 
     | 
    
         
            +
              <%= HighLine.default_instance.color "DESCRIPTION", :bold %>:
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                <%= Commander::HelpFormatter.indent 4, (@description || @summary || 'No description.') -%>
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            <% unless @examples.empty? -%>
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
              <%=  
     | 
| 
      
 19 
     | 
    
         
            +
              <%= HighLine.default_instance.color "EXAMPLES", :bold %>:
         
     | 
| 
       20 
20 
     | 
    
         
             
            	<% for description, command in @examples -%>
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                # <%= description %>
         
     | 
| 
         @@ -25,10 +25,10 @@ 
     | 
|
| 
       25 
25 
     | 
    
         
             
            <% end -%>
         
     | 
| 
       26 
26 
     | 
    
         
             
            <% unless @options.empty? -%>
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
              <%=  
     | 
| 
      
 28 
     | 
    
         
            +
              <%= HighLine.default_instance.color "OPTIONS", :bold %>:
         
     | 
| 
       29 
29 
     | 
    
         
             
            	<% for option in @options -%>
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                <%= option[:switches].join ', ' %> 
     | 
| 
      
 31 
     | 
    
         
            +
                <%= option[:switches].join ', ' %>
         
     | 
| 
       32 
32 
     | 
    
         
             
                    <%= Commander::HelpFormatter.indent 8, option[:description] %>
         
     | 
| 
       33 
33 
     | 
    
         
             
            	<% end -%>
         
     | 
| 
       34 
34 
     | 
    
         
             
            <% end -%>
         
     | 
| 
         @@ -1,34 +1,34 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
              <%=  
     | 
| 
      
 1 
     | 
    
         
            +
              <%= HighLine.default_instance.color "NAME", :bold %>:
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
                <%= program :name %>
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
              <%=  
     | 
| 
      
 5 
     | 
    
         
            +
              <%= HighLine.default_instance.color "DESCRIPTION", :bold %>:
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                <%= Commander::HelpFormatter.indent 4, program(:description) %>
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
              <%=  
     | 
| 
      
 9 
     | 
    
         
            +
              <%= HighLine.default_instance.color "COMMANDS", :bold %>:
         
     | 
| 
       10 
10 
     | 
    
         
             
            <% for name, command in @commands.sort -%>
         
     | 
| 
       11 
11 
     | 
    
         
             
            	<% unless alias? name %>
         
     | 
| 
       12 
12 
     | 
    
         
             
                <%= "%-#{max_command_length}s %s" % [command.name, command.summary || command.description] -%>
         
     | 
| 
       13 
13 
     | 
    
         
             
            	<% end -%>
         
     | 
| 
       14 
14 
     | 
    
         
             
            <% end %>
         
     | 
| 
       15 
15 
     | 
    
         
             
            <% unless @aliases.empty? %>
         
     | 
| 
       16 
     | 
    
         
            -
              <%=  
     | 
| 
      
 16 
     | 
    
         
            +
              <%= HighLine.default_instance.color "ALIASES", :bold %>:
         
     | 
| 
       17 
17 
     | 
    
         
             
              <% for alias_name, args in @aliases.sort %>
         
     | 
| 
       18 
18 
     | 
    
         
             
                <%= "%-#{max_aliases_length}s %s %s" % [alias_name, command(alias_name).name, args.join(' ')] -%>
         
     | 
| 
       19 
19 
     | 
    
         
             
              <% end %>
         
     | 
| 
       20 
20 
     | 
    
         
             
            <% end %>
         
     | 
| 
       21 
21 
     | 
    
         
             
            <% unless @options.empty? -%>
         
     | 
| 
       22 
     | 
    
         
            -
              <%=  
     | 
| 
      
 22 
     | 
    
         
            +
              <%= HighLine.default_instance.color "GLOBAL OPTIONS", :bold %>:
         
     | 
| 
       23 
23 
     | 
    
         
             
            	<% for option in @options -%>
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                <%= option[:switches].join ', ' %> 
     | 
| 
      
 25 
     | 
    
         
            +
                <%= option[:switches].join ', ' %>
         
     | 
| 
       26 
26 
     | 
    
         
             
                    <%= option[:description] %>
         
     | 
| 
       27 
27 
     | 
    
         
             
            	<% end -%>
         
     | 
| 
       28 
28 
     | 
    
         
             
            <% end -%>
         
     | 
| 
       29 
29 
     | 
    
         
             
            <% if program :help -%>
         
     | 
| 
       30 
30 
     | 
    
         
             
              <% for title, body in program(:help) %>
         
     | 
| 
       31 
     | 
    
         
            -
              <%=  
     | 
| 
      
 31 
     | 
    
         
            +
              <%= HighLine.default_instance.color title.to_s.upcase, :bold %>:
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                <%= body %>
         
     | 
| 
       34 
34 
     | 
    
         
             
              <% end -%>
         
     | 
    
        data/lib/commander/methods.rb
    CHANGED
    
    | 
         @@ -4,8 +4,8 @@ module Commander 
     | 
|
| 
       4 
4 
     | 
    
         
             
                include Commander::UI::AskForClass
         
     | 
| 
       5 
5 
     | 
    
         
             
                include Commander::Delegates
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                if $stdin.tty? && (cols =  
     | 
| 
       8 
     | 
    
         
            -
                   
     | 
| 
      
 7 
     | 
    
         
            +
                if $stdin.tty? && (cols = HighLine.default_instance.output_cols) >= 40
         
     | 
| 
      
 8 
     | 
    
         
            +
                  HighLine.default_instance.wrap_at = cols - 5
         
     | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
       10 
10 
     | 
    
         
             
              end
         
     | 
| 
       11 
11 
     | 
    
         
             
            end
         
     | 
    
        data/lib/commander/runner.rb
    CHANGED
    
    
| 
         @@ -66,7 +66,7 @@ module Commander 
     | 
|
| 
       66 
66 
     | 
    
         | 
| 
       67 
67 
     | 
    
         
             
                def say_ok(*args)
         
     | 
| 
       68 
68 
     | 
    
         
             
                  args.each do |arg|
         
     | 
| 
       69 
     | 
    
         
            -
                    say  
     | 
| 
      
 69 
     | 
    
         
            +
                    say HighLine.default_instance.color(arg, :green)
         
     | 
| 
       70 
70 
     | 
    
         
             
                  end
         
     | 
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
         @@ -80,7 +80,7 @@ module Commander 
     | 
|
| 
       80 
80 
     | 
    
         | 
| 
       81 
81 
     | 
    
         
             
                def say_warning(*args)
         
     | 
| 
       82 
82 
     | 
    
         
             
                  args.each do |arg|
         
     | 
| 
       83 
     | 
    
         
            -
                    say  
     | 
| 
      
 83 
     | 
    
         
            +
                    say HighLine.default_instance.color(arg, :yellow)
         
     | 
| 
       84 
84 
     | 
    
         
             
                  end
         
     | 
| 
       85 
85 
     | 
    
         
             
                end
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
         @@ -94,7 +94,7 @@ module Commander 
     | 
|
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                def say_error(*args)
         
     | 
| 
       96 
96 
     | 
    
         
             
                  args.each do |arg|
         
     | 
| 
       97 
     | 
    
         
            -
                    say  
     | 
| 
      
 97 
     | 
    
         
            +
                    say HighLine.default_instance.color(arg, :red)
         
     | 
| 
       98 
98 
     | 
    
         
             
                  end
         
     | 
| 
       99 
99 
     | 
    
         
             
                end
         
     | 
| 
       100 
100 
     | 
    
         | 
| 
         @@ -113,7 +113,7 @@ module Commander 
     | 
|
| 
       113 
113 
     | 
    
         
             
                #   * highligh: on_<color>
         
     | 
| 
       114 
114 
     | 
    
         | 
| 
       115 
115 
     | 
    
         
             
                def color(*args)
         
     | 
| 
       116 
     | 
    
         
            -
                  say  
     | 
| 
      
 116 
     | 
    
         
            +
                  say HighLine.default_instance.color(*args)
         
     | 
| 
       117 
117 
     | 
    
         
             
                end
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
       119 
119 
     | 
    
         
             
                ##
         
     | 
| 
         @@ -329,7 +329,7 @@ module Commander 
     | 
|
| 
       329 
329 
     | 
    
         
             
                  # define methods for common classes
         
     | 
| 
       330 
330 
     | 
    
         
             
                  [Float, Integer, String, Symbol, Regexp, Array, File, Pathname].each do |klass|
         
     | 
| 
       331 
331 
     | 
    
         
             
                    define_method "ask_for_#{klass.to_s.downcase}" do |prompt|
         
     | 
| 
       332 
     | 
    
         
            -
                       
     | 
| 
      
 332 
     | 
    
         
            +
                      HighLine.default_instance.ask(prompt, klass)
         
     | 
| 
       333 
333 
     | 
    
         
             
                    end
         
     | 
| 
       334 
334 
     | 
    
         
             
                  end
         
     | 
| 
       335 
335 
     | 
    
         | 
| 
         @@ -351,7 +351,7 @@ module Commander 
     | 
|
| 
       351 
351 
     | 
    
         | 
| 
       352 
352 
     | 
    
         
             
                      klass = available_classes.find { |k| k.to_s.downcase == requested_class }
         
     | 
| 
       353 
353 
     | 
    
         
             
                      if klass
         
     | 
| 
       354 
     | 
    
         
            -
                         
     | 
| 
      
 354 
     | 
    
         
            +
                        HighLine.default_instance.ask(prompt, klass)
         
     | 
| 
       355 
355 
     | 
    
         
             
                      else
         
     | 
| 
       356 
356 
     | 
    
         
             
                        super
         
     | 
| 
       357 
357 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -509,9 +509,9 @@ module Commander 
     | 
|
| 
       509 
509 
     | 
    
         
             
                    return if finished?
         
     | 
| 
       510 
510 
     | 
    
         
             
                    erase_line
         
     | 
| 
       511 
511 
     | 
    
         
             
                    if completed?
         
     | 
| 
       512 
     | 
    
         
            -
                       
     | 
| 
      
 512 
     | 
    
         
            +
                      HighLine.default_instance.say UI.replace_tokens(@complete_message, generate_tokens) if @complete_message.is_a? String
         
     | 
| 
       513 
513 
     | 
    
         
             
                    else
         
     | 
| 
       514 
     | 
    
         
            -
                       
     | 
| 
      
 514 
     | 
    
         
            +
                      HighLine.default_instance.say UI.replace_tokens(@format, generate_tokens) << ' '
         
     | 
| 
       515 
515 
     | 
    
         
             
                    end
         
     | 
| 
       516 
516 
     | 
    
         
             
                  end
         
     | 
| 
       517 
517 
     | 
    
         | 
| 
         @@ -544,7 +544,7 @@ module Commander 
     | 
|
| 
       544 
544 
     | 
    
         | 
| 
       545 
545 
     | 
    
         
             
                  def erase_line
         
     | 
| 
       546 
546 
     | 
    
         
             
                    # highline does not expose the output stream
         
     | 
| 
       547 
     | 
    
         
            -
                     
     | 
| 
      
 547 
     | 
    
         
            +
                    HighLine.default_instance.instance_variable_get('@output').print "\r\e[K"
         
     | 
| 
       548 
548 
     | 
    
         
             
                  end
         
     | 
| 
       549 
549 
     | 
    
         
             
                end
         
     | 
| 
       550 
550 
     | 
    
         
             
              end
         
     | 
    
        data/lib/commander/version.rb
    CHANGED
    
    
    
        data/spec/methods_spec.rb
    CHANGED
    
    | 
         @@ -16,12 +16,12 @@ describe Commander::Methods do 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  before do
         
     | 
| 
       18 
18 
     | 
    
         
             
                    allow(terminal).to receive(:ask)
         
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
       20 
     | 
    
         
            -
                     
     | 
| 
      
 19 
     | 
    
         
            +
                    @old_highline = HighLine.default_instance
         
     | 
| 
      
 20 
     | 
    
         
            +
                    HighLine.default_instance = terminal
         
     | 
| 
       21 
21 
     | 
    
         
             
                  end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                  after do
         
     | 
| 
       24 
     | 
    
         
            -
                     
     | 
| 
      
 24 
     | 
    
         
            +
                    HighLine.default_instance = @old_highline
         
     | 
| 
       25 
25 
     | 
    
         
             
                  end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                  subject do
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ require 'commander/methods' 
     | 
|
| 
       18 
18 
     | 
    
         
             
            def mock_terminal
         
     | 
| 
       19 
19 
     | 
    
         
             
              @input = StringIO.new
         
     | 
| 
       20 
20 
     | 
    
         
             
              @output = StringIO.new
         
     | 
| 
       21 
     | 
    
         
            -
               
     | 
| 
      
 21 
     | 
    
         
            +
              HighLine.default_instance = HighLine.new(@input, @output)
         
     | 
| 
       22 
22 
     | 
    
         
             
            end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
            # Create test command for usage within several specs
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: commander
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.4.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - TJ Holowaychuk
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2018-10-22 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: highline
         
     | 
| 
         @@ -17,14 +17,14 @@ dependencies: 
     | 
|
| 
       17 
17 
     | 
    
         
             
                requirements:
         
     | 
| 
       18 
18 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       19 
19 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       20 
     | 
    
         
            -
                    version:  
     | 
| 
      
 20 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
       21 
21 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       22 
22 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       23 
23 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       24 
24 
     | 
    
         
             
                requirements:
         
     | 
| 
       25 
25 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       26 
26 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       27 
     | 
    
         
            -
                    version:  
     | 
| 
      
 27 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
       28 
28 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       29 
29 
     | 
    
         
             
              name: rspec
         
     | 
| 
       30 
30 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |