gli 2.9.0 → 2.20.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 (94) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +28 -0
  3. data/.gitignore +3 -3
  4. data/.tool-versions +1 -0
  5. data/Gemfile +0 -2
  6. data/README.rdoc +29 -18
  7. data/Rakefile +15 -37
  8. data/bin/ci +29 -0
  9. data/bin/gli +24 -54
  10. data/bin/rake +29 -0
  11. data/bin/setup +5 -0
  12. data/exe/gli +68 -0
  13. data/gli.gemspec +20 -24
  14. data/gli.rdoc +9 -9
  15. data/lib/gli/app.rb +42 -8
  16. data/lib/gli/app_support.rb +17 -5
  17. data/lib/gli/argument.rb +20 -0
  18. data/lib/gli/command.rb +27 -2
  19. data/lib/gli/command_finder.rb +42 -25
  20. data/lib/gli/command_support.rb +13 -7
  21. data/lib/gli/commands/doc.rb +9 -3
  22. data/lib/gli/commands/help.rb +2 -1
  23. data/lib/gli/commands/help_modules/arg_name_formatter.rb +29 -2
  24. data/lib/gli/commands/help_modules/command_help_format.rb +19 -1
  25. data/lib/gli/commands/help_modules/full_synopsis_formatter.rb +5 -4
  26. data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
  27. data/lib/gli/commands/help_modules/options_formatter.rb +4 -6
  28. data/lib/gli/commands/initconfig.rb +3 -6
  29. data/lib/gli/commands/rdoc_document_listener.rb +2 -1
  30. data/lib/gli/commands/scaffold.rb +71 -142
  31. data/lib/gli/dsl.rb +25 -1
  32. data/lib/gli/exceptions.rb +26 -0
  33. data/lib/gli/flag.rb +23 -2
  34. data/lib/gli/gli_option_parser.rb +73 -21
  35. data/lib/gli/option_parser_factory.rb +10 -3
  36. data/lib/gli/options.rb +2 -2
  37. data/lib/gli/switch.rb +4 -0
  38. data/lib/gli/terminal.rb +6 -2
  39. data/lib/gli/version.rb +1 -1
  40. data/lib/gli.rb +2 -0
  41. data/object-model.dot +29 -0
  42. data/object-model.png +0 -0
  43. data/test/apps/todo/Gemfile +1 -1
  44. data/test/apps/todo/bin/todo +16 -6
  45. data/test/apps/todo/lib/todo/commands/create.rb +48 -18
  46. data/test/apps/todo/lib/todo/commands/list.rb +48 -35
  47. data/test/apps/todo/lib/todo/commands/ls.rb +25 -24
  48. data/test/apps/todo/lib/todo/commands/make.rb +42 -39
  49. data/test/apps/todo/todo.gemspec +1 -2
  50. data/test/apps/todo_legacy/todo.gemspec +1 -2
  51. data/test/apps/todo_plugins/commands/third.rb +2 -0
  52. data/test/integration/gli_cli_test.rb +69 -0
  53. data/test/integration/gli_powered_app_test.rb +52 -0
  54. data/test/integration/scaffold_test.rb +30 -0
  55. data/test/integration/test_helper.rb +52 -0
  56. data/test/unit/command_finder_test.rb +54 -0
  57. data/test/{tc_command.rb → unit/command_test.rb} +20 -7
  58. data/test/unit/compound_command_test.rb +17 -0
  59. data/test/{tc_doc.rb → unit/doc_test.rb} +38 -51
  60. data/test/{tc_flag.rb → unit/flag_test.rb} +19 -25
  61. data/test/{tc_gli.rb → unit/gli_test.rb} +92 -49
  62. data/test/{tc_help.rb → unit/help_test.rb} +54 -113
  63. data/test/{init_simplecov.rb → unit/init_simplecov.rb} +0 -0
  64. data/test/{tc_options.rb → unit/options_test.rb} +4 -4
  65. data/test/unit/subcommand_parsing_test.rb +263 -0
  66. data/test/unit/subcommands_test.rb +245 -0
  67. data/test/{fake_std_out.rb → unit/support/fake_std_out.rb} +0 -0
  68. data/test/{config.yaml → unit/support/gli_test_config.yml} +1 -0
  69. data/test/unit/switch_test.rb +49 -0
  70. data/test/{tc_terminal.rb → unit/terminal_test.rb} +28 -3
  71. data/test/unit/test_helper.rb +13 -0
  72. data/test/unit/verbatim_wrapper_test.rb +24 -0
  73. metadata +86 -141
  74. data/.ruby-gemset +0 -1
  75. data/.ruby-version +0 -1
  76. data/.travis.yml +0 -12
  77. data/ObjectModel.graffle +0 -1191
  78. data/bin/report_on_rake_results +0 -10
  79. data/bin/test_all_rubies.sh +0 -6
  80. data/features/gli_executable.feature +0 -90
  81. data/features/gli_init.feature +0 -232
  82. data/features/step_definitions/gli_executable_steps.rb +0 -18
  83. data/features/step_definitions/gli_init_steps.rb +0 -11
  84. data/features/step_definitions/todo_steps.rb +0 -96
  85. data/features/support/env.rb +0 -54
  86. data/features/todo.feature +0 -449
  87. data/features/todo_legacy.feature +0 -128
  88. data/test/option_test_helper.rb +0 -13
  89. data/test/tc_compound_command.rb +0 -22
  90. data/test/tc_subcommand_parsing.rb +0 -104
  91. data/test/tc_subcommands.rb +0 -259
  92. data/test/tc_switch.rb +0 -55
  93. data/test/tc_verbatim_wrapper.rb +0 -36
  94. data/test/test_helper.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d1fffe3ab7b8b3aa4881cfb38de3b7cc1e31508b
4
- data.tar.gz: 057ab9061b13527ed56f448cc20ee3ea54a7472d
2
+ SHA256:
3
+ metadata.gz: f99bcd6fc563c75307924a23694720c7a5a68d0957afbb7b25fb15e21257011c
4
+ data.tar.gz: 9e508b67d421593391c447f3778c90df01565f36e5db41cab83fce806bdc6417
5
5
  SHA512:
6
- metadata.gz: c61409e0f16a9d07d9e4f704e05890e48868dc359be530dd2c094d3856a841b224968c1f2902b761355ad3ff2574ab8e9a33af626ceb77e897e3a2dfa17a3580
7
- data.tar.gz: 3f26ab6c6026483c986241c506fdf1742a43408eac52605aa7ba2c5a36076f1d48acba70fbba5031b649fc042043d2cdf112ebc175cf9afeb35b49821fd15979
6
+ metadata.gz: bbfbd6572090c9a8b86ae7e165cbb3b12d5500fa3dda114bb1add6375ea32864e38b0857d29ba399deb3f45250d655ec61c6acb78d8c5bc9172c1e0eebfa0d20
7
+ data.tar.gz: 8ad9e606b644c9374a616cfd0d013ffc90909851d77f0b96fc366debb274e55698388e749756318db2437d23a640f4118459ada89b8d1ca1e035f507576611ff
@@ -0,0 +1,28 @@
1
+ version: 2.1
2
+ orbs:
3
+ # See https://circleci.com/developer/orbs/orb/circleci/ruby
4
+ ruby: circleci/ruby@1.1.2
5
+ jobs: # keyword
6
+ test: # my name for the job
7
+ parameters: # keyword
8
+ ruby-version: # my parameter name
9
+ type: string # type is a keyword
10
+ docker: # keyword
11
+ - image: cimg/base:stable
12
+ steps: # keyword
13
+ - checkout # magic name
14
+ - ruby/install: # ruby/ is from the orb name, install is a command in that orb
15
+ version: << parameters.ruby-version >> # magic nonsense for param subst (version param to the command)
16
+ - run:
17
+ command: "bin/setup"
18
+ - run:
19
+ command: "bin/ci"
20
+ workflows: # keyword
21
+ all-rubies: # my name for the workflow
22
+ jobs: # keyword
23
+ - test: # my name for the job
24
+ matrix: # keyword
25
+ parameters: # keyword
26
+ # All rubies being maintained per this page:
27
+ # https://www.ruby-lang.org/en/downloads/branches/
28
+ ruby-version: [ "2.5", "2.6", "2.7", "3.0" ]
data/.gitignore CHANGED
@@ -5,9 +5,9 @@ pkg
5
5
  coverage
6
6
  .bundle
7
7
  tmp
8
- cruddo.rdoc
9
- gli.wiki
10
8
  Gemfile.lock
9
+ *.gem
11
10
  results.html
12
- .rbx
13
11
  .DS_Store
12
+ Session.vim
13
+ scaffold_test
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.1
data/Gemfile CHANGED
@@ -2,7 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rcov", ">= 0.9.8", :platforms => :mri_18
6
5
  gem "simplecov", "~> 0.6.4", :platforms => :mri_19
7
6
  gem "psych", :platforms => :mri_19
8
-
data/README.rdoc CHANGED
@@ -1,16 +1,24 @@
1
- = Git-Like Interface Command Line Parser
1
+ = GLI, the Git-Like Interface Command Line Parser
2
2
 
3
- GLI is the best way to make a "command-suite" command-line application, e.g. one like <tt>git</tt> (for the best way to make a
4
- simpler command-line application, check out methadone[http://www.github.com/davetron5000/methadone]).
5
-
6
- GLI allows you to make a very polished, easy-to-maintain command-line application without a lot
7
- of syntax, but without restricting you in any way from the power of +OptionParser+.
3
+ GLI allows you to create command-line app in Ruby that behaves like <tt>git</tt> in that it takes subcommands to perform a series of complex action, e.g. <tt>git remote add</tt>.
8
4
 
9
5
  * {Overview}[http://davetron5000.github.com/gli]
10
6
  * {Source on Github}[http://github.com/davetron5000/gli]
11
7
  * RDoc[http://davetron5000.github.com/gli/rdoc/index.html]
12
8
 
13
- {<img src="https://secure.travis-ci.org/davetron5000/gli.png?branch=gli-2" alt="Build Status" />}[https://travis-ci.org/davetron5000/gli]
9
+ {<img src="https://secure.travis-ci.org/davetron5000/gli.svg?branch=gli-2" alt="Build Status" />}[https://travis-ci.org/davetron5000/gli]
10
+
11
+ == What Problem does GLI Solve?
12
+
13
+ Creating a command-line app that uses subcommands, each of which might accept different command-line options, is somewhat difficult with Ruby's built-in <tt>OptionParser</tt>. GLI provides an API that wraps <tt>OptionParser</tt> so that you can create a subcommand-based command-line app with minimal boilerplate. This API also produces complete documentation for your command-line app.
14
+
15
+ == Why is GLI's solution different from others?
16
+
17
+ There are other RubyGems that allow you to create a command-line app that takes subcommands. These solutions are often quite limited (e.g. they don't allow deeply nested subcommand structures or sophisticated command-line options per subcommand), or require more code that we think is needed. Some solutions make it difficult or impossible to properly document your command-line app.
18
+
19
+ == What you need to know to use GLI
20
+
21
+ You should know Ruby, and have a basic understanding of how the UNIX command line works: standard input, standard output, standard error, and exit codes.
14
22
 
15
23
  == Use
16
24
 
@@ -18,15 +26,26 @@ Install if you need to:
18
26
 
19
27
  gem install gli
20
28
 
29
+ You can validate you have installed it correctly by running <tt>gli help</tt>. You should see formatted help output.
30
+
31
+ If you are using GLI in another application, add it to your <tt>Gemfile</tt>:
32
+
33
+ gem "gli"
34
+
35
+ You can test your install via Bundler by running <tt>bundle exec gli help</tt>. This should produce formatted help output from GLI.
36
+
37
+ == Getting Started
38
+
21
39
  The simplest way to get started is to create a scaffold project
22
40
 
23
41
  gli init todo list add complete
24
42
 
43
+ (note if you installed via Bundler you will need to execute <tt>bundle exec gli init todo list add complete</tt>)
44
+
25
45
  This will create a basic scaffold project in <tt>./todo</tt> with:
26
46
 
27
47
  * executable in <tt>./todo/bin/todo</tt>. This file demonstrates most of what you need to describe your command line interface.
28
48
  * an empty test in <tt>./todo/test/default_test.rb</tt> that can bootstrap your tests
29
- * an empty feature in <tt>./todo/features/todo.feature</tt> that can bootstrap testing your CLI via Aruba.
30
49
  * a gemspec shell
31
50
  * a README shell
32
51
  * Rakefile that can generate RDoc, package your Gem and run tests
@@ -73,17 +92,9 @@ Get a more detailed walkthrough on the {main site}[http://davetron5000.github.co
73
92
 
74
93
  == Supported Platforms
75
94
 
76
- Known to work on
77
-
78
- * 1.8.7
79
- * 1.9.2
80
- * 1.9.3
81
- * 2.0.0
82
- * Ruby Enterprise Edition 1.8.7
83
- * Rubinius 1.0.1
84
- * JRuby 1.6.4
95
+ See `.circleci/config.yml` for the supported rubies, but general we're running tests on the all MRI rubies receiving support, which tends to be the most recent four versions.
85
96
 
86
- If you're interested in other versions of Ruby, let me know, and I'll add them to my test suite
97
+ GLI should work on older Rubies and JRuby, but it's too much work to keep tests passing for those.
87
98
 
88
99
  == Documentation
89
100
 
data/Rakefile CHANGED
@@ -3,8 +3,6 @@ require 'bundler'
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rdoc/task'
6
- require 'cucumber'
7
- require 'cucumber/rake/task'
8
6
 
9
7
  include Rake::DSL
10
8
 
@@ -75,48 +73,28 @@ end
75
73
 
76
74
  Bundler::GemHelper.install_tasks
77
75
 
78
- desc 'run unit tests'
79
- Rake::TestTask.new do |t|
76
+ desc "run unit tests"
77
+ Rake::TestTask.new("test:unit") do |t|
80
78
  t.libs << "test"
81
- t.test_files = FileList['test/init_simplecov.rb','test/tc_*.rb']
79
+ t.libs << "lib"
80
+ t.test_files = FileList["test/unit/**/*_test.rb"]
82
81
  end
83
82
 
84
- CUKE_RESULTS = 'results.html'
85
- CLEAN << CUKE_RESULTS
86
- Cucumber::Rake::Task.new(:features) do |t|
87
- opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
88
- opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
89
- t.cucumber_opts = opts
90
- t.fork = false
91
- end
92
- Cucumber::Rake::Task.new('features:wip') do |t|
93
- tag_opts = ' --tags ~@pending'
94
- tag_opts = ' --tags @wip'
95
- t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
96
- t.fork = false
97
- end
98
-
99
- begin
100
- require 'rcov/rcovtask'
101
- task :clobber_coverage do
102
- rm_rf "coverage"
83
+ desc "run integration tests"
84
+ Rake::TestTask.new("test:integration") do |t|
85
+ t.libs << "test"
86
+ explicitly_named_files = ARGV[1..-1]
87
+ if Array(explicitly_named_files).size == 0
88
+ t.test_files = FileList["test/integration/**/*_test.rb"]
89
+ else
90
+ t.test_files = explicitly_named_files
103
91
  end
92
+ end
104
93
 
105
- desc 'Measures test coverage'
106
- task :coverage => :rcov do
107
- puts "coverage/index.html contains what you need"
108
- end
109
94
 
110
- Rcov::RcovTask.new do |t|
111
- t.libs << 'lib'
112
- t.test_files = FileList['test/tc_*.rb']
113
- end
95
+ begin
96
+ require 'simplecov'
114
97
  rescue LoadError
115
- begin
116
- require 'simplecov'
117
- rescue LoadError
118
- $stderr.puts "neither rcov nor simplecov are installed; you won't be able to check code coverage"
119
- end
120
98
  end
121
99
 
122
100
  desc 'Publish rdoc on github pages and push to github'
data/bin/ci ADDED
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ if [ -z $1 ]; then
5
+ echo "[bin/ci] Running with default warnings"
6
+ export RUBYOPT=
7
+ else
8
+ if [ $1 == 'warnings' ]; then
9
+ echo "[bin/ci] Running with all warnings on"
10
+ export RUBYOPT=-w
11
+ else
12
+ if [ $1 == 'none' ]; then
13
+ echo "[bin/ci] Running with all warnings off"
14
+ export RUBYOPT='-W0'
15
+ else
16
+ echo "[bin/ci] '$1' is not a supported option"
17
+ echo "[bin/ci] usage: $0 # run with default warnings"
18
+ echo "[bin/ci] usage: $0 warnings # run with all warnings"
19
+ echo "[bin/ci] usage: $0 none # run with warnings disabled"
20
+ exit 1
21
+ fi
22
+ fi
23
+ fi
24
+
25
+ echo "[bin/ci] Running unit tests"
26
+ bin/rake test:unit
27
+
28
+ echo "[bin/ci] Running integration tests"
29
+ bin/rake test:integration
data/bin/gli CHANGED
@@ -1,59 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'gli'
4
- require 'gli/commands/scaffold'
5
-
6
- include GLI::App
7
-
8
- program_desc 'create scaffolding for a GLI-powered application'
9
-
10
- version GLI::VERSION
11
-
12
- switch :v, :desc => 'Be verbose'
13
-
14
- switch :n, :desc => 'Dry run; don''t change the disk'
15
-
16
- desc 'Root dir of project'
17
- long_desc <<EOS
18
- This is the directory where the project''s directory will be made, so if you
19
- specify a project name ''foo'' and the root dir of ''.'', the directory
20
- ''./foo'' will be created'
21
- EOS
22
-
23
- flag :r,:root, :default_value => '.'
24
-
25
- desc 'Create a new GLI-based project'
26
- long_desc <<EOS
27
- This will create a scaffold command line project that uses GLI
28
- for command line processing. Specifically, this will create
29
- an executable ready to go, as well as a lib and test directory, all
30
- inside the directory named for your project
31
- EOS
32
- arg_name 'project_name [command[ command]*]'
33
- command [:init,:scaffold] do |c|
34
-
35
- c.switch :e,:ext, :desc => 'Create an ext dir'
36
-
37
- c.switch :notest, :desc => 'Do not create a test or features dir', :negatable => false
38
-
39
- c.switch :force, :desc => 'Overwrite/ignore existing files and directories'
40
-
41
- c.switch :rvmrc, :desc => 'Create an .rvmrc based on your current RVM setup'
42
-
43
- c.action do |g,o,args|
44
- if args.length < 1
45
- raise 'You must specify the name of your project'
46
- end
47
- GLI::Commands::Scaffold.create_scaffold(g[:r],!o[:notest],o[:e],args[0],args[1..-1],o[:force],g[:n],o[:rvmrc])
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'gli' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
48
23
  end
49
24
  end
50
25
 
51
- pre do |global,command,options,args|
52
- puts "Executing #{command.name}" if global[:v]
53
- true
54
- end
26
+ require "rubygems"
27
+ require "bundler/setup"
55
28
 
56
- post do |global,command,options,args|
57
- puts "Executed #{command.name}" if global[:v]
58
- end
59
- exit run(ARGV)
29
+ load Gem.bin_path("gli", "gli")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ bundle check || bundle install
data/exe/gli ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gli'
4
+ require 'gli/commands/scaffold'
5
+
6
+ class App
7
+ extend GLI::App
8
+
9
+ program_desc 'create scaffolding for a GLI-powered application'
10
+
11
+ version GLI::VERSION
12
+
13
+ # Can't use these without changing the current behavior of gli
14
+ # arguments :strict
15
+ # subcommand_option_handling :normal
16
+
17
+ switch :v, :desc => 'Be verbose'
18
+
19
+ switch :n, :desc => 'Dry run; don''t change the disk'
20
+
21
+ desc 'Root dir of project'
22
+ long_desc <<EOS
23
+ This is the directory where the project''s directory will be made, so if you
24
+ specify a project name ''foo'' and the root dir of ''.'', the directory
25
+ ''./foo'' will be created'
26
+ EOS
27
+
28
+ flag :r,:root, :default_value => '.'
29
+
30
+ desc 'Create a new GLI-based project'
31
+ long_desc <<EOS
32
+ This will create a scaffold command line project that uses GLI
33
+ for command line processing. Specifically, this will create
34
+ an executable ready to go, as well as a lib and test directory, all
35
+ inside the directory named for your project
36
+ EOS
37
+ arg :project_name
38
+ arg :command_name, [:optional, :multiple]
39
+ arg_name "project_name [command_name]..."
40
+ command [:init,:scaffold] do |c|
41
+
42
+ c.switch :e,:ext, :desc => 'Create an ext dir'
43
+
44
+ c.switch :notest, :desc => 'Do not create a test or features dir', :negatable => false
45
+
46
+ c.switch :force, :desc => 'Overwrite/ignore existing files and directories'
47
+
48
+ c.switch :rvmrc, :desc => 'Create an .rvmrc based on your current RVM setup'
49
+
50
+ c.action do |g,o,args|
51
+ if args.length < 1
52
+ raise 'You must specify the name of your project'
53
+ end
54
+ GLI::Commands::Scaffold.create_scaffold(g[:r],!o[:notest],o[:e],args[0],args[1..-1],o[:force],g[:n],o[:rvmrc])
55
+ end
56
+ end
57
+
58
+ pre do |global,command,options,args|
59
+ puts "Executing #{command.name}" if global[:v]
60
+ true
61
+ end
62
+
63
+ post do |global,command,options,args|
64
+ puts "Executed #{command.name}" if global[:v]
65
+ end
66
+ end
67
+
68
+ exit App.run(ARGV)
data/gli.gemspec CHANGED
@@ -1,34 +1,30 @@
1
1
  # Make sure we get the gli that's local
2
- require File.join([File.dirname(__FILE__),'lib','gli','version.rb'])
2
+ require File.join([File.dirname(__FILE__),"lib","gli","version.rb"])
3
3
 
4
- spec = Gem::Specification.new do |s|
5
- s.name = 'gli'
4
+ spec = Gem::Specification.new do |s|
5
+ s.name = "gli"
6
6
  s.version = GLI::VERSION
7
- s.author = 'David Copeland'
8
- s.email = 'davidcopeland@naildrivin5.com'
9
- s.homepage = 'http://davetron5000.github.com/gli'
7
+ s.licenses = ["Apache-2.0"]
8
+ s.author = "David Copeland"
9
+ s.email = "davidcopeland@naildrivin5.com"
10
+ s.homepage = "http://davetron5000.github.com/gli"
10
11
  s.platform = Gem::Platform::RUBY
11
- s.summary = 'Build command-suite CLI apps that are awesome.'
12
- s.description = 'Build command-suite CLI apps that are awesome. Bootstrap your app, add commands, options and documentation while maintaining a well-tested idiomatic command-line app'
12
+ s.summary = "Build command-suite CLI apps that are awesome."
13
+ s.description = "Build command-suite CLI apps that are awesome. Bootstrap your app, add commands, options and documentation while maintaining a well-tested idiomatic command-line app"
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = 'gli'
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.has_rdoc = true
20
- s.extra_rdoc_files = ['README.rdoc', 'gli.rdoc']
21
- s.rdoc_options << '--title' << 'Git Like Interface' << '--main' << 'README.rdoc'
22
- s.bindir = 'bin'
23
- s.rubyforge_project = 'gli'
24
- s.add_development_dependency('rake', '~> 0.9.2.2')
25
- s.add_development_dependency('rdoc', '~> 3.11')
26
- s.add_development_dependency('rainbow', '~> 1.1.1')
27
- s.add_development_dependency('clean_test')
28
- s.add_development_dependency('cucumber', '1.2.3')
29
- s.add_development_dependency('gherkin', '<= 2.11.6')
30
- s.add_development_dependency('aruba', '0.5.1') # 0.5.3 randomly breaks with "LaunchError: no such file or directory" and only sometimes.
31
- s.add_development_dependency('sdoc')
32
- s.add_development_dependency('faker','1.0.0')
33
- end
19
+ s.extra_rdoc_files = ["README.rdoc", "gli.rdoc"]
20
+ s.rdoc_options << "--title" << "Git Like Interface" << "--main" << "README.rdoc"
21
+
22
+ s.bindir = "exe"
23
+ s.executables = "gli"
34
24
 
25
+ s.add_development_dependency("rake", "~> 0.9.2.2")
26
+ s.add_development_dependency("rdoc", "~> 4.2")
27
+ s.add_development_dependency("rainbow", "~> 1.1", "~> 1.1.1")
28
+ s.add_development_dependency("sdoc", "~> 0.4")
29
+ s.add_development_dependency("minitest")
30
+ end
data/gli.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  == gli - create scaffolding for a GLI-powered application
2
2
 
3
- v2.2.1
3
+ v2.19.2
4
4
 
5
5
  === Global Options
6
6
  === -r|--root arg
@@ -8,9 +8,9 @@ v2.2.1
8
8
  Root dir of project
9
9
 
10
10
  [Default Value] .
11
- This is the directory where the project''s directory will be made, so if you
12
- specify a project name ''foo'' and the root dir of ''.'', the directory
13
- ''./foo'' will be created'
11
+ This is the directory where the project''s directory will be made, so if you
12
+ specify a project name ''foo'' and the root dir of ''.'', the directory
13
+ ''./foo'' will be created'
14
14
 
15
15
  === --help
16
16
  Show this message
@@ -28,7 +28,7 @@ Be verbose
28
28
 
29
29
 
30
30
  === --version
31
-
31
+ Display the program version
32
32
 
33
33
 
34
34
 
@@ -43,13 +43,13 @@ List commands one per line, to assist with shell completion
43
43
 
44
44
 
45
45
 
46
- ==== Command: <tt>init|scaffold project_name [command[ command]*]</tt>
46
+ ==== Command: <tt>init|scaffold project_name [command_name]...</tt>
47
47
  Create a new GLI-based project
48
48
 
49
49
  This will create a scaffold command line project that uses GLI
50
- for command line processing. Specifically, this will create
51
- an executable ready to go, as well as a lib and test directory, all
52
- inside the directory named for your project
50
+ for command line processing. Specifically, this will create
51
+ an executable ready to go, as well as a lib and test directory, all
52
+ inside the directory named for your project
53
53
  ===== Options
54
54
  ===== -e|--[no-]ext
55
55
  Create an ext dir
data/lib/gli/app.rb CHANGED
@@ -30,7 +30,7 @@ module GLI
30
30
  # # loads *.rb files from the user's home dir - great and an extension/plugin mechanism
31
31
  # commands_from File.join(ENV["HOME"],".my_app","plugins")
32
32
  def commands_from(path)
33
- if Pathname.new(path).absolute? and File.exists?(path)
33
+ if Pathname.new(path).absolute? and File.exist?(path)
34
34
  load_commands(path)
35
35
  else
36
36
  $LOAD_PATH.each do |load_path|
@@ -62,6 +62,17 @@ module GLI
62
62
  @program_long_desc
63
63
  end
64
64
 
65
+ # Provide a flag to choose whether to hide or not from the help the undescribed commands.
66
+ # By default the undescribed commands will be shown in the help.
67
+ #
68
+ # hide:: A Bool for hide the undescribed commands
69
+ def hide_commands_without_desc(hide=nil)
70
+ unless hide.nil?
71
+ @hide_commands_without_desc = hide
72
+ end
73
+ @hide_commands_without_desc || false
74
+ end
75
+
65
76
  # Use this if the following command should not have the pre block executed.
66
77
  # By default, the pre block is executed before each command and can result in
67
78
  # aborting the call. Using this will avoid that behavior for the following command
@@ -83,7 +94,7 @@ module GLI
83
94
  @skips_around = true
84
95
  end
85
96
 
86
- # Sets that this app uses a config file as well as the name of the config file.
97
+ # Sets that this app uses a config file as well as the name of the config file.
87
98
  #
88
99
  # +filename+:: A String representing the path to the file to use for the config file. If it's an absolute
89
100
  # path, this is treated as the path to the file. If it's *not*, it's treated as relative to the user's home
@@ -141,7 +152,7 @@ module GLI
141
152
  # Define a block to run if an error occurs.
142
153
  # The block will receive any Exception that was caught.
143
154
  # It should evaluate to false to avoid the built-in error handling (which basically just
144
- # prints out a message). GLI uses a variety of exceptions that you can use to find out what
155
+ # prints out a message). GLI uses a variety of exceptions that you can use to find out what
145
156
  # errors might've occurred during command-line parsing:
146
157
  # * GLI::CustomExit
147
158
  # * GLI::UnknownCommandArgument
@@ -154,7 +165,7 @@ module GLI
154
165
 
155
166
  # Indicate the version of your application
156
167
  #
157
- # +version+:: String containing the version of your application.
168
+ # +version+:: String containing the version of your application.
158
169
  def version(version)
159
170
  @version = version
160
171
  desc 'Display the program version'
@@ -180,7 +191,7 @@ module GLI
180
191
  end
181
192
 
182
193
  # Configure a type conversion not already provided by the underlying OptionParser.
183
- # This works more or less like the OptionParser version.
194
+ # This works more or less like the OptionParser version. It's global.
184
195
  #
185
196
  # object:: the class (or whatever) that triggers the type conversion
186
197
  # block:: the block that will be given the string argument and is expected
@@ -190,7 +201,7 @@ module GLI
190
201
  #
191
202
  # accept(Hash) do |value|
192
203
  # result = {}
193
- # value.split(/,/) do |pair|
204
+ # value.split(/,/).each do |pair|
194
205
  # k,v = pair.split(/:/)
195
206
  # result[k] = v
196
207
  # end
@@ -202,7 +213,7 @@ module GLI
202
213
  accepts[object] = block
203
214
  end
204
215
 
205
- # Simpler means of exiting with a custom exit code. This will
216
+ # Simpler means of exiting with a custom exit code. This will
206
217
  # raise a CustomExit with the given message and exit code, which will ultimatley
207
218
  # cause your application to exit with the given exit_code as its exit status
208
219
  # Use #help_now! if you want to show the help in addition to the error message
@@ -280,10 +291,33 @@ module GLI
280
291
  @subcommand_option_handling_strategy = handling_strategy
281
292
  end
282
293
 
294
+ # How to handle argument validation.
295
+ #
296
+ # handling_strategy:: One of:
297
+ # +:loose+:: no argument validation. Use of `arg` or `arg_name` is for documentation purposes only. (Default)
298
+ # +:strict+:: arguments are validated according to their specification. +action+ blocks may assume
299
+ # the value of `arguments` matches the specification provided in `arg`. Note that to use
300
+ # this strategy, you must also be sure that +subcommand_option_handling+ is set.
301
+ def arguments(handling_strategy)
302
+ @argument_handling_strategy = handling_strategy
303
+ end
304
+
305
+
306
+ # Enables/Disables command autocomplete, where partially spelled commands are automatically expanded to their full form
307
+ #
308
+ # Example:
309
+ # When enabled, executing 'shake' would execute 'shake_hand' (if no 'shake' command is defined).
310
+ # When disabled, executing 'shake' would throw an UnknownCommand error
311
+ #
312
+ # +boolean+:: Boolean value to enable or disable autocomplete, respectively. True by default.
313
+ def autocomplete_commands(boolean)
314
+ @autocomplete = boolean
315
+ end
316
+
283
317
  private
284
318
 
285
319
  def load_commands(path)
286
- if File.exists? path
320
+ if File.exist? path
287
321
  Dir.entries(path).sort.each do |entry|
288
322
  file = File.join(path,entry)
289
323
  if file =~ /\.rb$/