gli_aziz_light 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +17 -0
  6. data/CONTRIBUTING.md +23 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE.txt +201 -0
  9. data/ObjectModel.graffle +1191 -0
  10. data/README.rdoc +109 -0
  11. data/Rakefile +126 -0
  12. data/bin/gli +59 -0
  13. data/bin/report_on_rake_results +10 -0
  14. data/bin/test_all_rubies.sh +6 -0
  15. data/features/gli_executable.feature +90 -0
  16. data/features/gli_init.feature +232 -0
  17. data/features/step_definitions/gli_executable_steps.rb +18 -0
  18. data/features/step_definitions/gli_init_steps.rb +11 -0
  19. data/features/step_definitions/todo_steps.rb +88 -0
  20. data/features/support/env.rb +53 -0
  21. data/features/todo.feature +413 -0
  22. data/features/todo_legacy.feature +128 -0
  23. data/gli.cheat +95 -0
  24. data/gli.gemspec +34 -0
  25. data/gli.rdoc +73 -0
  26. data/lib/gli.rb +35 -0
  27. data/lib/gli/app.rb +286 -0
  28. data/lib/gli/app_support.rb +341 -0
  29. data/lib/gli/command.rb +171 -0
  30. data/lib/gli/command_finder.rb +41 -0
  31. data/lib/gli/command_line_option.rb +34 -0
  32. data/lib/gli/command_line_token.rb +63 -0
  33. data/lib/gli/command_support.rb +181 -0
  34. data/lib/gli/commands/compound_command.rb +42 -0
  35. data/lib/gli/commands/doc.rb +231 -0
  36. data/lib/gli/commands/help.rb +95 -0
  37. data/lib/gli/commands/help_modules/arg_name_formatter.rb +20 -0
  38. data/lib/gli/commands/help_modules/command_finder.rb +60 -0
  39. data/lib/gli/commands/help_modules/command_help_format.rb +156 -0
  40. data/lib/gli/commands/help_modules/global_help_format.rb +70 -0
  41. data/lib/gli/commands/help_modules/help_completion_format.rb +31 -0
  42. data/lib/gli/commands/help_modules/list_formatter.rb +23 -0
  43. data/lib/gli/commands/help_modules/one_line_wrapper.rb +18 -0
  44. data/lib/gli/commands/help_modules/options_formatter.rb +49 -0
  45. data/lib/gli/commands/help_modules/text_wrapper.rb +53 -0
  46. data/lib/gli/commands/help_modules/tty_only_wrapper.rb +23 -0
  47. data/lib/gli/commands/help_modules/verbatim_wrapper.rb +16 -0
  48. data/lib/gli/commands/initconfig.rb +74 -0
  49. data/lib/gli/commands/rdoc_document_listener.rb +116 -0
  50. data/lib/gli/commands/scaffold.rb +401 -0
  51. data/lib/gli/dsl.rb +226 -0
  52. data/lib/gli/exceptions.rb +71 -0
  53. data/lib/gli/flag.rb +68 -0
  54. data/lib/gli/gli_option_block_parser.rb +84 -0
  55. data/lib/gli/gli_option_parser.rb +156 -0
  56. data/lib/gli/option_parser_factory.rb +81 -0
  57. data/lib/gli/option_parsing_result.rb +21 -0
  58. data/lib/gli/options.rb +23 -0
  59. data/lib/gli/switch.rb +35 -0
  60. data/lib/gli/terminal.rb +101 -0
  61. data/lib/gli/version.rb +5 -0
  62. data/test/apps/README.md +2 -0
  63. data/test/apps/todo/Gemfile +2 -0
  64. data/test/apps/todo/README.rdoc +6 -0
  65. data/test/apps/todo/Rakefile +23 -0
  66. data/test/apps/todo/bin/todo +63 -0
  67. data/test/apps/todo/lib/todo/commands/create.rb +24 -0
  68. data/test/apps/todo/lib/todo/commands/list.rb +63 -0
  69. data/test/apps/todo/lib/todo/commands/ls.rb +47 -0
  70. data/test/apps/todo/lib/todo/commands/make.rb +52 -0
  71. data/test/apps/todo/lib/todo/version.rb +3 -0
  72. data/test/apps/todo/test/tc_nothing.rb +14 -0
  73. data/test/apps/todo/todo.gemspec +23 -0
  74. data/test/apps/todo/todo.rdoc +5 -0
  75. data/test/apps/todo_legacy/Gemfile +2 -0
  76. data/test/apps/todo_legacy/README.rdoc +6 -0
  77. data/test/apps/todo_legacy/Rakefile +23 -0
  78. data/test/apps/todo_legacy/bin/todo +61 -0
  79. data/test/apps/todo_legacy/lib/todo/commands/create.rb +24 -0
  80. data/test/apps/todo_legacy/lib/todo/commands/list.rb +63 -0
  81. data/test/apps/todo_legacy/lib/todo/commands/ls.rb +47 -0
  82. data/test/apps/todo_legacy/lib/todo/version.rb +3 -0
  83. data/test/apps/todo_legacy/test/tc_nothing.rb +14 -0
  84. data/test/apps/todo_legacy/todo.gemspec +23 -0
  85. data/test/apps/todo_legacy/todo.rdoc +5 -0
  86. data/test/apps/todo_plugins/commands/third.rb +1 -0
  87. data/test/config.yaml +10 -0
  88. data/test/fake_std_out.rb +30 -0
  89. data/test/init_simplecov.rb +8 -0
  90. data/test/option_test_helper.rb +13 -0
  91. data/test/tc_command.rb +508 -0
  92. data/test/tc_compound_command.rb +22 -0
  93. data/test/tc_doc.rb +325 -0
  94. data/test/tc_flag.rb +62 -0
  95. data/test/tc_gli.rb +773 -0
  96. data/test/tc_help.rb +387 -0
  97. data/test/tc_options.rb +43 -0
  98. data/test/tc_subcommand_parsing.rb +104 -0
  99. data/test/tc_subcommands.rb +260 -0
  100. data/test/tc_switch.rb +55 -0
  101. data/test/tc_terminal.rb +100 -0
  102. data/test/tc_verbatim_wrapper.rb +36 -0
  103. data/test/test_helper.rb +20 -0
  104. metadata +330 -0
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # These would not be in a real GLI app; we do this so we can easily run this on the command line
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','lib'))
5
+ $: << File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+
7
+ require 'gli'
8
+ require 'todo/version'
9
+
10
+
11
+ if ENV['GLI1_COMPATIBILITY']
12
+ include GLI
13
+ else
14
+ include GLI::App
15
+ end
16
+
17
+ sort_help (ENV['TODO_SORT_HELP'] || 'alpha').to_sym
18
+ wrap_help_text (ENV['TODO_WRAP_HELP_TEXT'] || 'to_terminal').to_sym
19
+
20
+ subcommand_option_handling :normal
21
+
22
+ program_desc 'Manages tasks'
23
+ program_long_desc "A test program that has a sophisticated UI that can be used to exercise a lot of GLI's power"
24
+
25
+ config_file "gli_test_todo.rc"
26
+
27
+ flag :flag
28
+ switch :switch
29
+ switch :otherswitch, :negatable => true
30
+
31
+ version Todo::VERSION
32
+
33
+ commands_from 'todo/commands'
34
+ commands_from File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'todo_plugins', 'commands'))
35
+
36
+ command :first do |c| c.action { |g,o,a| puts "first: #{a.join(',')}" } end
37
+ command :second do |c| c.action { |g,o,a| puts "second: #{a.join(',')}" } end
38
+
39
+ command :chained => [ :first, :second ]
40
+ command [:chained2,:ch2] => [ :second, :first ]
41
+
42
+ pre do |global,command,options,args|
43
+ # Pre logic here
44
+ # Return true to proceed; false to abort and not call the
45
+ # chosen command
46
+ # Use skips_pre before a command to skip this block
47
+ # on that command only
48
+ true
49
+ end
50
+
51
+ post do |global,command,options,args|
52
+ # Post logic here
53
+ # Use skips_post before a command to skip this
54
+ # block on that command only
55
+ end
56
+
57
+ on_error do |exception|
58
+ # Error logic here
59
+ # return false to skip default error handling
60
+ true
61
+ end
62
+
63
+ exit run(ARGV)
@@ -0,0 +1,24 @@
1
+ desc "Create a new task or context"
2
+ command [:create,:new] do |c|
3
+ c.desc "Make a new task"
4
+ c.arg_name 'task_name', :multiple
5
+ c.command :tasks do |tasks|
6
+ tasks.action do |global,options,args|
7
+ puts "#{args}"
8
+ end
9
+ end
10
+
11
+ c.desc "Make a new context"
12
+ c.arg_name 'context_name', :optional
13
+ c.command :contexts do |contexts|
14
+ contexts.action do |global,options,args|
15
+ puts "#{args}"
16
+ end
17
+ end
18
+
19
+ c.default_desc "Makes a new task"
20
+ c.action do
21
+ puts "default action"
22
+ end
23
+ end
24
+
@@ -0,0 +1,63 @@
1
+ desc "List things, such as tasks or contexts"
2
+ long_desc %(
3
+ List a whole lot of things that you might be keeping track of
4
+ in your overall todo list.
5
+
6
+ This is your go-to place or finding all of the things that you
7
+ might have
8
+ stored in
9
+ your todo databases.
10
+ )
11
+ command [:list] do |c|
12
+ c.default_command :tasks
13
+
14
+ c.desc "Show long form"
15
+ c.switch [:l,:long]
16
+
17
+ c.desc "List tasks"
18
+ c.long_desc %(
19
+ Lists all of your tasks that you have, in varying orders, and
20
+ all that stuff. Yes, this is long, but I need a long description.
21
+ )
22
+ c.command :tasks do |tasks|
23
+ tasks.desc "blah blah crud x whatever"
24
+ tasks.flag [:x], :must_match => Array
25
+
26
+ tasks.flag :flag
27
+
28
+ tasks.action do |global,options,args|
29
+ puts options[:x].inspect
30
+ puts "list tasks: #{args.join(',')}"
31
+ end
32
+
33
+ tasks.desc 'list open tasks'
34
+ tasks.command :open do |open|
35
+ open.action do |global,options,args|
36
+ puts "tasks open"
37
+ end
38
+ end
39
+
40
+ tasks.default_desc 'list all tasks'
41
+ end
42
+
43
+ c.desc "List contexts"
44
+ c.long_desc %(
45
+ Lists all of your contexts, which are places you might be
46
+ where you can do stuff and all that.
47
+ )
48
+ c.command :contexts do |contexts|
49
+
50
+ contexts.desc "Foobar"
51
+ contexts.switch [:f,'foobar']
52
+
53
+ contexts.desc "Blah"
54
+ contexts.switch [:b]
55
+
56
+ contexts.flag :otherflag
57
+
58
+ contexts.action do |global,options,args|
59
+ puts "list contexts: #{args.join(',')}"
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,47 @@
1
+ # This is copied so I can have two slightly different versions of the same thing
2
+ desc "LS things, such as tasks or contexts"
3
+ long_desc %(
4
+ List a whole lot of things that you might be keeping track of
5
+ in your overall todo list.
6
+
7
+ This is your go-to place or finding all of the things that you
8
+ might have
9
+ stored in
10
+ your todo databases.
11
+ )
12
+ command [:ls] do |c|
13
+ c.desc "Show long form"
14
+ c.switch [:l,:long]
15
+
16
+ c.desc "List tasks"
17
+ c.long_desc %(
18
+ Lists all of your tasks that you have, in varying orders, and
19
+ all that stuff. Yes, this is long, but I need a long description.
20
+ )
21
+ c.command :tasks do |tasks|
22
+ tasks.desc "blah blah crud x whatever"
23
+ tasks.flag [:x]
24
+ tasks.action do |global,options,args|
25
+ puts "ls tasks: #{args.join(',')}"
26
+ end
27
+ end
28
+
29
+ c.desc "List contexts"
30
+ c.long_desc %(
31
+ Lists all of your contexts, which are places you might be
32
+ where you can do stuff and all that.
33
+ )
34
+ c.command :contexts do |contexts|
35
+
36
+ contexts.desc "Foobar"
37
+ contexts.switch [:f,'foobar']
38
+
39
+ contexts.desc "Blah"
40
+ contexts.switch [:b]
41
+
42
+ contexts.action do |global,options,args|
43
+ puts "ls contexts: #{args.join(',')}"
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,52 @@
1
+ command [:make] do |c|
2
+ c.desc "Show long form"
3
+ c.flag [:l,:long]
4
+
5
+ c.desc 'make a new task'
6
+ c.command :task do |task|
7
+ task.desc 'make the task a long task'
8
+ task.flag [:l,:long]
9
+
10
+ task.action do |g,o,a|
11
+ puts 'new task'
12
+ puts a.join(',')
13
+ puts o[:long]
14
+ end
15
+
16
+ desc 'make a bug'
17
+ task.command :bug do |bug|
18
+ bug.desc 'make this bug in the legacy system'
19
+ bug.flag [:l,:legacy]
20
+
21
+ bug.action do |g,o,a|
22
+ puts 'new task bug'
23
+ puts a.join(',')
24
+ # All this .to_s is to make sure 1.8.7/REE don't convert nil to the string "nil"
25
+ puts o[:legacy].to_s
26
+ puts o[:long].to_s
27
+ puts o[:l].to_s
28
+ puts o[GLI::Command::PARENT][:l].to_s
29
+ puts o[GLI::Command::PARENT][:long].to_s
30
+ puts o[GLI::Command::PARENT][:legacy].to_s
31
+ puts o[GLI::Command::PARENT][GLI::Command::PARENT][:l].to_s
32
+ puts o[GLI::Command::PARENT][GLI::Command::PARENT][:long].to_s
33
+ puts o[GLI::Command::PARENT][GLI::Command::PARENT][:legacy].to_s
34
+ end
35
+ end
36
+ end
37
+
38
+ c.desc 'make a new context'
39
+ c.command :context do |context|
40
+ context.desc 'make the context a local context'
41
+ context.flag [:l,:local]
42
+
43
+ context.action do |g,o,a|
44
+ puts 'new context'
45
+ puts a.join(',')
46
+ puts o[:local].to_s
47
+ puts o[:long].to_s
48
+ puts o[:l].to_s
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,3 @@
1
+ module Todo
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'test/unit'
2
+
3
+ class TC_testNothing < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_the_truth
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','todo','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'todo'
5
+ s.version = Todo::VERSION
6
+ s.author = 'Your Name Here'
7
+ s.email = 'your@email.address.com'
8
+ s.homepage = 'http://your.website.com'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'A description of your project'
11
+ # Add your other files here if you make them
12
+ s.files = %w(
13
+ bin/todo
14
+ )
15
+ s.require_paths << 'lib'
16
+ s.has_rdoc = true
17
+ s.extra_rdoc_files = ['README.rdoc','todo.rdoc']
18
+ s.rdoc_options << '--title' << 'todo' << '--main' << 'README.rdoc' << '-ri'
19
+ s.bindir = 'bin'
20
+ s.executables << 'todo'
21
+ s.add_development_dependency('rake')
22
+ s.add_development_dependency('rdoc')
23
+ end
@@ -0,0 +1,5 @@
1
+ = todo
2
+
3
+ Generate this with
4
+ todo rdoc
5
+ After you have described your command line interface
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,6 @@
1
+ = todo
2
+
3
+ Describe your project here
4
+
5
+ :include:todo.rdoc
6
+
@@ -0,0 +1,23 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/rdoctask'
5
+
6
+ Rake::RDocTask.new do |rd|
7
+ rd.main = "README.rdoc"
8
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
9
+ rd.title = 'Your application title'
10
+ end
11
+
12
+ spec = eval(File.read('todo.gemspec'))
13
+
14
+ Rake::GemPackageTask.new(spec) do |pkg|
15
+ end
16
+
17
+ require 'rake/testtask'
18
+ Rake::TestTask.new do |t|
19
+ t.libs << "test"
20
+ t.test_files = FileList['test/tc_*.rb']
21
+ end
22
+
23
+ task :default => :test
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # These would not be in a real GLI app; we do this so we can easily run this on the command line
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','lib'))
5
+ $: << File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+
7
+ require 'gli'
8
+ require 'todo/version'
9
+
10
+
11
+ if ENV['GLI1_COMPATIBILITY']
12
+ include GLI
13
+ else
14
+ include GLI::App
15
+ end
16
+
17
+ sort_help (ENV['TODO_SORT_HELP'] || 'alpha').to_sym
18
+ wrap_help_text (ENV['TODO_WRAP_HELP_TEXT'] || 'to_terminal').to_sym
19
+
20
+ program_desc 'Manages tasks'
21
+ program_long_desc "A test program that has a sophisticated UI that can be used to exercise a lot of GLI's power"
22
+
23
+ config_file "gli_test_todo.rc"
24
+
25
+ flag :flag
26
+ switch :switch
27
+ switch :otherswitch, :negatable => true
28
+
29
+ version Todo::VERSION
30
+
31
+ commands_from 'todo/commands'
32
+ commands_from File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'todo_plugins', 'commands'))
33
+
34
+ command :first do |c| c.action { |g,o,a| puts "first: #{a.join(',')}" } end
35
+ command :second do |c| c.action { |g,o,a| puts "second: #{a.join(',')}" } end
36
+
37
+ command :chained => [ :first, :second ]
38
+ command [:chained2,:ch2] => [ :second, :first ]
39
+
40
+ pre do |global,command,options,args|
41
+ # Pre logic here
42
+ # Return true to proceed; false to abort and not call the
43
+ # chosen command
44
+ # Use skips_pre before a command to skip this block
45
+ # on that command only
46
+ true
47
+ end
48
+
49
+ post do |global,command,options,args|
50
+ # Post logic here
51
+ # Use skips_post before a command to skip this
52
+ # block on that command only
53
+ end
54
+
55
+ on_error do |exception|
56
+ # Error logic here
57
+ # return false to skip default error handling
58
+ true
59
+ end
60
+
61
+ exit run(ARGV)
@@ -0,0 +1,24 @@
1
+ desc "Create a new task or context"
2
+ command [:create,:new] do |c|
3
+ c.desc "Make a new task"
4
+ c.arg_name 'task_name', :multiple
5
+ c.command :tasks do |tasks|
6
+ tasks.action do |global,options,args|
7
+ puts "#{args}"
8
+ end
9
+ end
10
+
11
+ c.desc "Make a new context"
12
+ c.arg_name 'context_name', :optional
13
+ c.command :contexts do |contexts|
14
+ contexts.action do |global,options,args|
15
+ puts "#{args}"
16
+ end
17
+ end
18
+
19
+ c.default_desc "Makes a new task"
20
+ c.action do
21
+ puts "default action"
22
+ end
23
+ end
24
+
@@ -0,0 +1,63 @@
1
+ desc "List things, such as tasks or contexts"
2
+ long_desc %(
3
+ List a whole lot of things that you might be keeping track of
4
+ in your overall todo list.
5
+
6
+ This is your go-to place or finding all of the things that you
7
+ might have
8
+ stored in
9
+ your todo databases.
10
+ )
11
+ command [:list] do |c|
12
+ c.default_command :tasks
13
+
14
+ c.desc "Show long form"
15
+ c.switch [:l,:long]
16
+
17
+ c.desc "List tasks"
18
+ c.long_desc %(
19
+ Lists all of your tasks that you have, in varying orders, and
20
+ all that stuff. Yes, this is long, but I need a long description.
21
+ )
22
+ c.command :tasks do |tasks|
23
+ tasks.desc "blah blah crud x whatever"
24
+ tasks.flag [:x], :must_match => Array
25
+
26
+ tasks.flag :flag
27
+
28
+ tasks.action do |global,options,args|
29
+ puts options[:x].inspect
30
+ puts "list tasks: #{args.join(',')}"
31
+ end
32
+
33
+ tasks.desc 'list open tasks'
34
+ tasks.command :open do |open|
35
+ open.action do |global,options,args|
36
+ puts "tasks open"
37
+ end
38
+ end
39
+
40
+ tasks.default_desc 'list all tasks'
41
+ end
42
+
43
+ c.desc "List contexts"
44
+ c.long_desc %(
45
+ Lists all of your contexts, which are places you might be
46
+ where you can do stuff and all that.
47
+ )
48
+ c.command :contexts do |contexts|
49
+
50
+ contexts.desc "Foobar"
51
+ contexts.switch [:f,'foobar']
52
+
53
+ contexts.desc "Blah"
54
+ contexts.switch [:b]
55
+
56
+ contexts.flag :otherflag
57
+
58
+ contexts.action do |global,options,args|
59
+ puts "list contexts: #{args.join(',')}"
60
+ end
61
+ end
62
+ end
63
+