gli 2.5.6 → 2.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/features/step_definitions/todo_steps.rb +4 -0
- data/features/todo.feature +22 -0
- data/features/todo_legacy.feature +128 -0
- data/lib/gli.rb +3 -1
- data/lib/gli/app.rb +10 -2
- data/lib/gli/app_support.rb +39 -31
- data/lib/gli/command.rb +3 -2
- data/lib/gli/command_finder.rb +41 -0
- data/lib/gli/command_line_token.rb +0 -4
- data/lib/gli/command_support.rb +37 -64
- data/lib/gli/commands/doc.rb +12 -2
- data/lib/gli/commands/help.rb +3 -0
- data/lib/gli/commands/help_modules/command_help_format.rb +22 -5
- data/lib/gli/commands/scaffold.rb +1 -1
- data/lib/gli/exceptions.rb +17 -5
- data/lib/gli/gli_option_block_parser.rb +84 -0
- data/lib/gli/gli_option_parser.rb +116 -96
- data/lib/gli/option_parser_factory.rb +42 -10
- data/lib/gli/option_parsing_result.rb +19 -0
- data/lib/gli/version.rb +1 -1
- data/test/apps/todo/bin/todo +2 -0
- data/test/apps/todo/lib/todo/commands/make.rb +52 -0
- data/test/apps/todo_legacy/Gemfile +2 -0
- data/test/apps/todo_legacy/README.rdoc +6 -0
- data/test/apps/todo_legacy/Rakefile +23 -0
- data/test/apps/todo_legacy/bin/todo +61 -0
- data/test/apps/todo_legacy/lib/todo/commands/create.rb +24 -0
- data/test/apps/todo_legacy/lib/todo/commands/list.rb +63 -0
- data/test/apps/todo_legacy/lib/todo/commands/ls.rb +47 -0
- data/test/apps/todo_legacy/lib/todo/version.rb +3 -0
- data/test/apps/todo_legacy/test/tc_nothing.rb +14 -0
- data/test/apps/todo_legacy/todo.gemspec +23 -0
- data/test/apps/todo_legacy/todo.rdoc +5 -0
- data/test/tc_command.rb +84 -59
- data/test/{tc_compount_command.rb → tc_compound_command.rb} +0 -0
- data/test/tc_flag.rb +0 -1
- data/test/tc_gli.rb +2 -2
- data/test/tc_help.rb +11 -3
- data/test/tc_subcommand_parsing.rb +104 -0
- data/test/tc_subcommands.rb +1 -0
- data/test/tc_switch.rb +0 -1
- data/test/test_helper.rb +5 -0
- metadata +74 -13
- data/lib/gli/copy_options_to_aliases.rb +0 -33
@@ -1,33 +0,0 @@
|
|
1
|
-
module GLI
|
2
|
-
|
3
|
-
# Mixin that both GLI and Command can use to copy command-line options to the aliased versions
|
4
|
-
# of flags and switches
|
5
|
-
#
|
6
|
-
# includers must provide the methods +flags+ and +switches+ that return an Array of Flag or Switch,
|
7
|
-
# respectively
|
8
|
-
module CopyOptionsToAliases # :nodoc:
|
9
|
-
# For each option in options, copies its value to keys for the aliases of the flags or
|
10
|
-
# switches in gli_like
|
11
|
-
#
|
12
|
-
# options - Hash of options parsed from command line; this is an I/O param
|
13
|
-
def copy_options_to_aliases(options) # :nodoc:
|
14
|
-
new_options = {}
|
15
|
-
options.each do |key,value|
|
16
|
-
if flags[key] && flags[key].aliases
|
17
|
-
copy_aliases(flags[key].aliases,new_options,value)
|
18
|
-
elsif switches[key] && switches[key].aliases
|
19
|
-
copy_aliases(switches[key].aliases,new_options,value)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
options.merge!(new_options)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def copy_aliases(aliases,new_options,value)
|
28
|
-
aliases.each do |alias_name|
|
29
|
-
new_options[alias_name] = value
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|