convoy 1.1.0 → 1.2.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/convoy.gemspec +14 -11
  3. data/examples/basic_depends_on +2 -2
  4. data/lib/convoy/action_command/base.rb +9 -9
  5. data/lib/convoy/app.rb +13 -13
  6. data/lib/convoy/error/error.rb +2 -2
  7. data/lib/convoy/formatter/command.rb +2 -2
  8. data/lib/convoy/formatter/commands.rb +1 -1
  9. data/lib/convoy/formatter/default_help_formatter.rb +14 -21
  10. data/lib/convoy/formatter/option.rb +2 -2
  11. data/lib/convoy/formatter/options.rb +2 -2
  12. data/lib/convoy/formatter/shell_command_executor.rb +1 -1
  13. data/lib/convoy/formatter/stream_output_formatter.rb +10 -10
  14. data/lib/convoy/formatter/string_grid.rb +3 -3
  15. data/lib/convoy/formatter/string_splitter.rb +1 -1
  16. data/lib/convoy/global_pre_parser.rb +2 -2
  17. data/lib/convoy/logger.rb +3 -3
  18. data/lib/convoy/option_parser.rb +13 -13
  19. data/lib/convoy/setup/configuration/generator.rb +7 -7
  20. data/lib/convoy/setup/configuration/loader.rb +1 -1
  21. data/lib/convoy/setup/configuration/locator/executing_script_directory.rb +1 -1
  22. data/lib/convoy/setup/dsl/command.rb +10 -10
  23. data/lib/convoy/setup/dsl/global.rb +1 -1
  24. data/lib/convoy/setup/dsl/options.rb +7 -7
  25. data/lib/convoy/setup_accessor.rb +5 -5
  26. data/lib/convoy/trollop.rb +42 -33
  27. data/lib/convoy/utils.rb +2 -2
  28. data/spec/integration/basic_config_file_spec.rb +3 -3
  29. data/spec/integration/basic_depends_on_spec.rb +2 -2
  30. data/spec/lib/convoy/action_command/base_spec.rb +32 -32
  31. data/spec/lib/convoy/formatter/option_spec.rb +1 -1
  32. data/spec/lib/convoy/formatter/stream_output_formatter_spec.rb +1 -1
  33. data/spec/lib/convoy/setup/configuration/merge_tool_spec.rb +10 -10
  34. data/spec/lib/convoy/setup/configuration/reader_spec.rb +3 -3
  35. data/spec/lib/convoy/setup/configuration/writer_spec.rb +12 -12
  36. data/spec/lib/convoy/utils_spec.rb +2 -2
  37. data/spec/spec_helper.rb +1 -1
  38. data/spec/support/shared_contexts/integration_setup.rb +5 -5
  39. data/version.rb +1 -0
  40. metadata +24 -5
  41. data/.ruby-version +0 -1
  42. data/.travis.yml +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dce20ef0475a98ad8e3db17accdd52cf40df9402
4
- data.tar.gz: f2cc919519e7b9ced080175d7630713536c5feac
3
+ metadata.gz: 59707815dce44c3eeb7596a097d6e363b25dd3bd
4
+ data.tar.gz: a53418545a1796617d42b6f554f920a9f4a16302
5
5
  SHA512:
6
- metadata.gz: daa739a479de1c0685623e4686d6f4422a23ee1981de993d29bf5880f222ab70211d22bf80dba6ef1b5c865bf479eb577d06573433cd225b92facd9c7bb5dcc9
7
- data.tar.gz: dcac8c553f276f5f623b3f68fc943c78a5a92b9a8118a29d78e2e8bdf28d748f739210a69216da78107acb826c0820961a0687726a5833a557c9dd7a653811ba
6
+ metadata.gz: 171f9831e51cb817a983833b55fbf6a865495067f35d5b56f06847ec4f7abb616cf8df8d6ab883c3c47fe3d40c486a85205436c6c19673ca4573f0f7af17504b
7
+ data.tar.gz: f723e0993a9b3710a94b1256152307de5cd8bda51db5c8563697e164389de50e65752b56603af439c3f256e21ec6bd299dbe4553537fdc1253d982296e91e51a
data/convoy.gemspec CHANGED
@@ -2,20 +2,23 @@ $LOAD_PATH << File.expand_path(File.join('..', 'lib'), __FILE__)
2
2
 
3
3
  require 'date'
4
4
 
5
+ require_relative 'version'
6
+
5
7
  Gem::Specification.new do |s|
6
- s.name = 'convoy'
7
- s.version = '1.1.0'
8
- s.date = Date.today.to_s
9
- s.summary = %q{A library that makes building command line apps in ruby so easy, you'll feel like an expert is guiding you through it}
10
- s.description = %q{Writing even complex command-line apps should be quick, easy and fun. Convoy takes the excellent Trollop option parser and adds a whole bunch of awesome features to produce a library you will always want to turn to when a 'quick script' is in order.}
11
- s.authors = ['Albert Rannetsperger']
12
- s.email = 'alb3rtuk@hotmail.com'
13
- s.homepage = 'http://github.com/alb3rtuk/convoy'
14
- s.license = 'MIT'
8
+ s.name = 'convoy'
9
+ s.version = CONVOY_VERSION
10
+ s.date = Date.today.to_s
11
+ s.summary = %q{A library that makes building command line apps in ruby so easy, you'll feel like an expert is guiding you through it}
12
+ s.description = %q{Writing even complex command-line apps should be quick, easy and fun. Convoy takes the excellent Trollop option parser and adds a whole bunch of awesome features to produce a library you will always want to turn to when a 'quick script' is in order.}
13
+ s.authors = ['Albert Rannetsperger']
14
+ s.email = 'alb3rtuk@hotmail.com'
15
+ s.homepage = 'http://github.com/alb3rtuk/convoy'
16
+ s.license = 'MIT'
15
17
  s.require_paths = ['lib']
16
- s.files = `git ls-files`.split($/)
17
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.files = `git ls-files`.split($/)
19
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
20
  s.add_runtime_dependency 'nesty', '~> 1.0', '>= 1.0.2'
21
+ s.add_runtime_dependency 'blufin-lib', '1.5.0', '>= 1.5.0'
19
22
  s.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
20
23
  s.add_development_dependency 'fakefs', '~> 0.5', '>= 0.5.3'
21
24
  s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
@@ -14,9 +14,9 @@ Convoy::App.create do |app|
14
14
 
15
15
  opts.dependency :option1, :on => :flag1
16
16
  opts.dependency :option2, :on => [:flag1, :option1]
17
- opts.dependency :option3, :on => {:option1 => 'foo'}
17
+ opts.dependency :option3, :on => { :option1 => 'foo' }
18
18
  #opts.dependency :option4, :on => [{:flag1 => false}, :option1] #This will get you into big trouble as it can never be fulfilled
19
- opts.dependency :option4, :on => [{:flag2 => false}, :option1]
19
+ opts.dependency :option4, :on => [{ :flag2 => false }, :option1]
20
20
  end
21
21
 
22
22
  app.action do |options, arguments|
@@ -4,22 +4,22 @@ module Convoy
4
4
  attr_reader :options, :arguments, :config
5
5
 
6
6
  def initialize(options, arguments, config={})
7
- @options = options
8
- @arguments = arguments
9
- @config = config
10
- @command_context = nil
11
- @command_options = nil
12
- @parent_options = nil
7
+ @options = options
8
+ @arguments = arguments
9
+ @config = config
10
+ @command_context = nil
11
+ @command_options = nil
12
+ @parent_options = nil
13
13
  @grandparent_options = nil
14
- @global_options = nil
14
+ @global_options = nil
15
15
  end
16
16
 
17
17
  protected
18
18
 
19
19
  def command_context
20
20
  return @command_context if @command_context
21
- @command_context = []
22
- options[:global] ||= {}
21
+ @command_context = []
22
+ options[:global] ||= {}
23
23
  current_command_hash = options[:global][:commands] || {}
24
24
  until current_command_hash.keys.empty?
25
25
  key = current_command_hash.keys.first
data/lib/convoy/app.rb CHANGED
@@ -12,16 +12,16 @@ module Convoy
12
12
 
13
13
  def initialize(option_string, &block)
14
14
  @option_string = option_string
15
- @setup = nil
16
- @block = block
15
+ @setup = nil
16
+ @block = block
17
17
  end
18
18
 
19
19
  def setup_application
20
20
  old_error_sev_threshold = error_logger.sev_threshold
21
21
  begin
22
22
  error_logger.sev_threshold = ::Logger::DEBUG
23
- cli_app_configuration = Convoy::Setup::Dsl::Global.new(&@block)
24
- @setup = Convoy::SetupAccessor.new(cli_app_configuration)
23
+ cli_app_configuration = Convoy::Setup::Dsl::Global.new(&@block)
24
+ @setup = Convoy::SetupAccessor.new(cli_app_configuration)
25
25
  self
26
26
  rescue => e
27
27
  handle_convoy_error(e)
@@ -44,9 +44,9 @@ module Convoy
44
44
  configuration = Convoy::Setup::Configuration::Loader.new(setup, auto_options).configuration
45
45
 
46
46
  invoked_options, arguments = Convoy::OptionParser.new(configuration, setup).parse(cli_options)
47
- context = context_from_options(invoked_options[:global])
48
- action = setup.action_for(context)
49
- current_command = context.empty? ? :global : context.last
47
+ context = context_from_options(invoked_options[:global])
48
+ action = setup.action_for(context)
49
+ current_command = context.empty? ? :global : context.last
50
50
  raise Convoy::ClientError.new("No action defined for command '#{current_command}'") unless action
51
51
  actual_arguments = Convoy::Arguments.read(arguments, setup.arguments_required_for(context))
52
52
  rescue => e
@@ -89,15 +89,15 @@ module Convoy
89
89
  def handle_convoy_error(e)
90
90
  if e.kind_of?(Convoy::UserError)
91
91
  print_stacktrace(e)
92
- error_logger.debug {'Convoy app failed to execute successfully, due to user error'}
92
+ error_logger.debug { 'Convoy app failed to execute successfully, due to user error' }
93
93
  exit(Convoy::USER_ERROR_EXIT_CODE)
94
94
  elsif e.kind_of?(Convoy::ClientError)
95
95
  print_stacktrace(e)
96
- error_logger.debug {'Convoy app failed to execute successfully, due to client setup error'}
96
+ error_logger.debug { 'Convoy app failed to execute successfully, due to client setup error' }
97
97
  exit(Convoy::CLIENT_ERROR_EXIT_CODE)
98
98
  else
99
99
  print_convoy_error_message(e)
100
- error_logger.debug {'Convoy app failed to execute successfully, due to internal error'}
100
+ error_logger.debug { 'Convoy app failed to execute successfully, due to internal error' }
101
101
  exit(Convoy::INTERNAL_ERROR_EXIT_CODE)
102
102
  end
103
103
  end
@@ -105,11 +105,11 @@ module Convoy
105
105
  def handle_action_error(e)
106
106
  if e.kind_of?(Convoy::Error)
107
107
  print_convoy_error_message(e)
108
- error_logger.debug {'Convoy app failed to execute successfully, due to internal error'}
108
+ error_logger.debug { 'Convoy app failed to execute successfully, due to internal error' }
109
109
  exit(Convoy::INTERNAL_ERROR_EXIT_CODE)
110
110
  else
111
111
  print_stacktrace(e)
112
- error_logger.debug {'Convoy app failed to execute successfully, due to unknown error'}
112
+ error_logger.debug { 'Convoy app failed to execute successfully, due to unknown error' }
113
113
  exit(Convoy::EXTERNAL_ERROR_EXIT_CODE)
114
114
  end
115
115
  end
@@ -121,7 +121,7 @@ module Convoy
121
121
 
122
122
  def print_convoy_error_message(e)
123
123
  print_stacktrace(e)
124
- error_logger.warn {"\n \x1B[48;5;196m ERROR \x1B[0m An internal Convoy error occurred.\n\n You should probably report it to \x1B[38;5;222mAlbert Rannetsperger\x1B[0m or create an issue on his \x1B[38;5;222mGitHub\x1B[0m page (https://github.com/alb3rtuk).\n Make sure to include the stacktrace above (although the way Ruby works, it probably won't be very helpful).\n"}
124
+ error_logger.warn { "\n \x1B[48;5;196m Error \x1B[0m \xe2\x86\x92 An internal Convoy error occurred.\n\n You should probably report it to \x1B[38;5;222mAlbert Rannetsperger\x1B[0m or create an issue on his \x1B[38;5;222mGitHub\x1B[0m page (https://github.com/alb3rtuk).\n Make sure to include the stacktrace above (although the way Ruby works, it probably won't be very helpful).\n" }
125
125
  end
126
126
  end
127
127
  end
@@ -1,7 +1,7 @@
1
1
  module Convoy
2
2
  INTERNAL_ERROR_EXIT_CODE = 1
3
- CLIENT_ERROR_EXIT_CODE = 2
4
- USER_ERROR_EXIT_CODE = 3
3
+ CLIENT_ERROR_EXIT_CODE = 2
4
+ USER_ERROR_EXIT_CODE = 3
5
5
  EXTERNAL_ERROR_EXIT_CODE = 10
6
6
 
7
7
  #module to tag all exceptions coming out of Convoy with
@@ -4,9 +4,9 @@ module Convoy
4
4
  attr_reader :setup, :context, :name
5
5
 
6
6
  def initialize(command_name, setup, context)
7
- @setup = setup
7
+ @setup = setup
8
8
  @context = context
9
- @name = command_name.to_sym
9
+ @name = command_name.to_sym
10
10
  end
11
11
 
12
12
  def name_with_aliases
@@ -16,7 +16,7 @@ module Convoy
16
16
  attr_reader :setup, :context
17
17
 
18
18
  def initialize(setup, context)
19
- @setup = setup
19
+ @setup = setup
20
20
  @context = context
21
21
  end
22
22
 
@@ -4,13 +4,13 @@ module Convoy
4
4
  attr_reader :setup, :context
5
5
 
6
6
  def initialize(setup, context)
7
- @setup = setup
7
+ @setup = setup
8
8
  @context = context
9
9
  end
10
10
 
11
11
  def print(parser)
12
- options = Options.new(parser, setup, context)
13
- commands = Commands.new(setup, context)
12
+ options = Options.new(parser, setup, context)
13
+ commands = Commands.new(setup, context)
14
14
  current_command = Commands.command_for(setup, context)
15
15
  # Uncomment the following line if you want the screen
16
16
  # to be cleared before the --help messages show.
@@ -27,8 +27,8 @@ module Convoy
27
27
  # end
28
28
  # end
29
29
  name_help(current_command, f)
30
- usage_help(current_command, f)
31
30
  version_help(current_command, f)
31
+ usage_help(current_command, f)
32
32
  commands_help(commands, f)
33
33
  options_help(options, f)
34
34
  end
@@ -37,37 +37,30 @@ module Convoy
37
37
  private
38
38
 
39
39
  def name_help(current_command, f)
40
- # f.puts "\x1B[38;5;84mNAME\x1B[0m"
41
40
  if setup.description_for(context) != ''
42
41
  f.indent(4) do |f|
43
- # f.grid(:columns => 3) do |t|
44
- # t.row current_command.script_name, '-', setup.summary_for(context)
45
- # end
46
- # f.newline
47
- f.puts(setup.description_for(context), :newlines => 2)
42
+ f.puts("\x1B[38;5;250m#{setup.description_for(context)}\x1B[0m", :newlines => 2)
48
43
  end
49
44
  end
50
45
  end
51
46
 
52
- def usage_help(current_command, f)
53
- f.puts "\x1B[38;5;84mUSAGE\x1B[0m"
54
- f.indent(4) do |f|
55
- f.puts current_command.usage, :newlines => 2
56
- end
57
- end
58
-
59
47
  def version_help(current_command, f)
60
48
  if setup.version
61
- f.puts "\x1B[38;5;84mVERSION\x1B[0m"
62
49
  f.indent(4) do |f|
63
- f.puts setup.version, :newlines => 2
50
+ f.puts "\x1B[38;5;250mVersion: \x1B[38;5;46m#{setup.version}\x1B[0m", :newlines => 1
64
51
  end
65
52
  end
66
53
  end
67
54
 
55
+ def usage_help(current_command, f)
56
+ f.indent(4) do |f|
57
+ f.puts "\x1B[38;5;250m Usage: \x1B[38;5;46m#{current_command.usage}\x1B[0m", :newlines => 2
58
+ end
59
+ end
60
+
68
61
  def options_help(options, f)
69
62
  if options.count > 0
70
- f.puts "\x1B[38;5;84mFLAGS\x1B[0m"
63
+ f.puts " \x1B[38;5;255mFLAGS\x1B[0m"
71
64
  f.indent(4) do |f|
72
65
  f.grid(:columns => 3) do |t|
73
66
  options.each do |option|
@@ -106,7 +99,7 @@ module Convoy
106
99
 
107
100
  def commands_help(commands, f)
108
101
  if commands.count > 0
109
- f.puts "\x1B[38;5;84mCOMMANDS\x1B[0m"
102
+ f.puts " \x1B[38;5;255mCOMMANDS\x1B[0m"
110
103
  f.indent(4) do |f|
111
104
  f.grid(:columns => 3) do |t|
112
105
  commands.each do |command|
@@ -4,9 +4,9 @@ module Convoy
4
4
  attr_reader :name, :details, :setup, :context
5
5
 
6
6
  def initialize(name, details, setup, context)
7
- @name = name.to_sym
7
+ @name = name.to_sym
8
8
  @details = details
9
- @setup = setup
9
+ @setup = setup
10
10
  @context = context
11
11
  end
12
12
 
@@ -6,8 +6,8 @@ module Convoy
6
6
  attr_reader :parser, :setup, :context
7
7
 
8
8
  def initialize(parser, setup, context)
9
- @parser = parser
10
- @setup = setup
9
+ @parser = parser
10
+ @setup = setup
11
11
  @context = context
12
12
  end
13
13
 
@@ -11,7 +11,7 @@ module Convoy
11
11
 
12
12
  def execute_in_current_shell(success_callback = nil, error_callback = nil)
13
13
  begin
14
- result = `#{command}`
14
+ result = `#{command}`
15
15
  process_status = $?
16
16
  raise Convoy::InternalError.new("Shell command exited with a non-zero (#{process_status.exitstatus}) exit code") if process_status.exitstatus != 0
17
17
  success_callback.call(command, result) if success_callback
@@ -1,25 +1,25 @@
1
1
  module Convoy
2
2
  module Formatter
3
3
  class StreamOutputFormatter
4
- DEFAULT_OUTPUT_WIDTH = 80
4
+ DEFAULT_OUTPUT_WIDTH = 80
5
5
  DEFAULT_INDENT_STRING = ' '
6
- DEFAULT_INDENT = 0
6
+ DEFAULT_INDENT = 0
7
7
 
8
8
  attr_reader :stream, :indent_string, :current_indent, :max_output_width, :cursor_position
9
9
 
10
10
  def initialize(stream = $stdout, options = {}, &block)
11
- @stream = stream
11
+ @stream = stream
12
12
  @max_output_width = options[:max_output_width] || DEFAULT_OUTPUT_WIDTH
13
- @indent_string = options[:indent_string] || DEFAULT_INDENT_STRING
14
- @current_indent = options[:current_indent] || DEFAULT_INDENT
15
- @cursor_position = CursorPosition.new(@max_output_width)
13
+ @indent_string = options[:indent_string] || DEFAULT_INDENT_STRING
14
+ @current_indent = options[:current_indent] || DEFAULT_INDENT
15
+ @cursor_position = CursorPosition.new(@max_output_width)
16
16
  block.call(self) if block_given?
17
17
  end
18
18
 
19
19
  def print(string)
20
20
  splitter_input = pad_string_to_account_for_cursor_position(string.to_s)
21
- segments = StringSplitter.new(max_output_width).split(splitter_input)
22
- segments = remove_padding_that_account_for_cursor_position(segments)
21
+ segments = StringSplitter.new(max_output_width).split(splitter_input)
22
+ segments = remove_padding_that_account_for_cursor_position(segments)
23
23
  segments.each do |segment|
24
24
  output_string = "#{current_indent_string}#{segment}"
25
25
  output_string = segment unless cursor_position.newline?
@@ -29,7 +29,7 @@ module Convoy
29
29
  end
30
30
  end
31
31
 
32
- def puts(string, options = {:newlines => 1})
32
+ def puts(string, options = { :newlines => 1 })
33
33
  print(string)
34
34
  newline(options[:newlines])
35
35
  end
@@ -48,7 +48,7 @@ module Convoy
48
48
  def grid(options = {}, &block)
49
49
  if block_given?
50
50
  options[:width] ||= max_output_width
51
- grid = StringGrid.new(options, &block)
51
+ grid = StringGrid.new(options, &block)
52
52
  puts grid.to_s
53
53
  end
54
54
  end
@@ -7,9 +7,9 @@ module Convoy
7
7
  attr_accessor :rows
8
8
 
9
9
  def initialize(options = {}, &block)
10
- @width = options[:width] || DEFAULT_WIDTH
10
+ @width = options[:width] || DEFAULT_WIDTH
11
11
  @column_count = options[:columns] || 3
12
- @rows = []
12
+ @rows = []
13
13
  block.call(self) if block_given?
14
14
  end
15
15
 
@@ -80,7 +80,7 @@ module Convoy
80
80
  end
81
81
 
82
82
  def last_column_width
83
- full_fair_column_width = max_column_width * column_count + max_column_width_remainder
83
+ full_fair_column_width = max_column_width * column_count + max_column_width_remainder
84
84
  all_but_last_fair_column_width = 0
85
85
  (column_count - 1).times do |index|
86
86
  all_but_last_fair_column_width += fair_column_width(index)
@@ -36,7 +36,7 @@ module Convoy
36
36
  def split_string(string)
37
37
  result = []
38
38
  if string.length > max_segment_width
39
- first_part = string.slice(0, max_segment_width)
39
+ first_part = string.slice(0, max_segment_width)
40
40
  second_part = string.slice(max_segment_width..-1)
41
41
  result << first_part
42
42
  result << split_string(second_part)
@@ -14,8 +14,8 @@ module Convoy
14
14
 
15
15
  def parse_global_options(cli_options, context = [])
16
16
  stop_words = setup.command_names_for(context).map(&:to_s)
17
- parser = init_parser(stop_words)
18
- parser = add_setup_options_to(parser, context)
17
+ parser = init_parser(stop_words)
18
+ parser = add_setup_options_to(parser, context)
19
19
  parser.version(setup.version) #set the version if it was provided
20
20
  parser.help_formatter(Convoy::Formatter::DefaultHelpFormatter.new(setup, context))
21
21
  parsed_options = parse_options_string(parser, cli_options)
data/lib/convoy/logger.rb CHANGED
@@ -11,14 +11,14 @@ module Convoy
11
11
  def error
12
12
  @error_logger ||= ::Logger.new($stderr).tap do |l|
13
13
  #l.formatter = advanced_error_formatter
14
- l.formatter = basic_error_formatter
14
+ l.formatter = basic_error_formatter
15
15
  l.sev_threshold = ::Logger::WARN
16
16
  end
17
17
  end
18
18
 
19
19
  def output
20
20
  @output_logger ||= ::Logger.new($stdout).tap do |l|
21
- l.formatter = output_formatter
21
+ l.formatter = output_formatter
22
22
  l.sev_threshold = ::Logger::DEBUG
23
23
  l.instance_eval do
24
24
  def puts(message = nil, &block)
@@ -33,7 +33,7 @@ module Convoy
33
33
  end
34
34
 
35
35
  def setup_error_logger(auto_options)
36
- error.formatter = send(:"#{auto_options.error_formatter}_error_formatter")
36
+ error.formatter = send(:"#{auto_options.error_formatter}_error_formatter")
37
37
  error.sev_threshold = ::Logger.const_get(auto_options.verbosity)
38
38
  end
39
39
 
@@ -4,7 +4,7 @@ module Convoy
4
4
 
5
5
  def initialize(configuration, setup)
6
6
  @configuration = configuration
7
- @setup = setup
7
+ @setup = setup
8
8
  end
9
9
 
10
10
  def parse(cli_options)
@@ -20,7 +20,7 @@ module Convoy
20
20
  def init_invoked_options_hash
21
21
  {
22
22
  :global => {
23
- :options => {},
23
+ :options => {},
24
24
  :commands => {}
25
25
  }
26
26
  }
@@ -37,9 +37,9 @@ module Convoy
37
37
  else
38
38
  command = command_name_from(cli_options)
39
39
  context << command
40
- current_options = parse_options(cli_options, context)
41
- options[command] = {}
42
- options[command][:options] = current_options
40
+ current_options = parse_options(cli_options, context)
41
+ options[command] = {}
42
+ options[command][:options] = current_options
43
43
  options[command][:commands] = {}
44
44
  parse_command_options(cli_options, context, options[command][:commands])
45
45
  end
@@ -47,10 +47,10 @@ module Convoy
47
47
 
48
48
  def parse_options(cli_options, context = [])
49
49
  stop_words = setup.command_names_for(context).map(&:to_s)
50
- parser = init_parser(stop_words)
51
- parser = add_setup_options_to(parser, context)
52
- parser = add_option_conflicts_to(parser, context)
53
- parser = default_option_values_from_config_for(parser, context)
50
+ parser = init_parser(stop_words)
51
+ parser = add_setup_options_to(parser, context)
52
+ parser = add_option_conflicts_to(parser, context)
53
+ parser = default_option_values_from_config_for(parser, context)
54
54
  parser.version(setup.version) #set the version if it was provided
55
55
  parser.help_formatter(Convoy::Formatter::DefaultHelpFormatter.new(setup, context))
56
56
  parsed_options = parse_options_string(parser, cli_options)
@@ -86,7 +86,7 @@ module Convoy
86
86
  unless configuration.empty?
87
87
  parser.specs.each do |sym, opts|
88
88
  if config_has_value_for_context?(sym, context)
89
- default = config_value_for_context(sym, context)
89
+ default = config_value_for_context(sym, context)
90
90
  opts[:default] = default
91
91
  if opts[:multi] && default.nil?
92
92
  opts[:default] = [] # multi arguments default to [], not nil
@@ -114,7 +114,7 @@ module Convoy
114
114
  def config_hash_for_context(context)
115
115
  relevant_config_hash = configuration.global
116
116
  context.each do |command_name|
117
- command_name = command_name.to_sym
117
+ command_name = command_name.to_sym
118
118
  relevant_config_hash = relevant_config_hash[:commands][command_name]
119
119
  relevant_config_hash = ensure_config_hash_has_options_and_commands(relevant_config_hash)
120
120
  end
@@ -122,9 +122,9 @@ module Convoy
122
122
  end
123
123
 
124
124
  def ensure_config_hash_has_options_and_commands(relevant_config_hash)
125
- relevant_config_hash ||= {}
125
+ relevant_config_hash ||= {}
126
126
  relevant_config_hash[:commands] ||= {}
127
- relevant_config_hash[:options] ||= {}
127
+ relevant_config_hash[:options] ||= {}
128
128
  relevant_config_hash
129
129
  end
130
130