gli 1.6.0 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +11 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +10 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE.txt +201 -0
  6. data/ObjectModel.graffle +1191 -0
  7. data/README.rdoc +60 -10
  8. data/Rakefile +145 -0
  9. data/bin/gli +12 -30
  10. data/bin/report_on_rake_results +10 -0
  11. data/bin/test_all_rubies.sh +6 -0
  12. data/features/gli_executable.feature +84 -0
  13. data/features/gli_init.feature +219 -0
  14. data/features/step_definitions/gli_executable_steps.rb +12 -0
  15. data/features/step_definitions/gli_init_steps.rb +11 -0
  16. data/features/step_definitions/todo_steps.rb +69 -0
  17. data/features/support/env.rb +49 -0
  18. data/features/todo.feature +182 -0
  19. data/gli.cheat +95 -0
  20. data/gli.gemspec +34 -0
  21. data/lib/gli.rb +11 -571
  22. data/lib/gli/app.rb +184 -0
  23. data/lib/gli/app_support.rb +226 -0
  24. data/lib/gli/command.rb +107 -95
  25. data/lib/gli/command_line_option.rb +34 -0
  26. data/lib/gli/command_line_token.rb +13 -9
  27. data/lib/gli/command_support.rb +200 -0
  28. data/lib/gli/commands/compound_command.rb +42 -0
  29. data/lib/gli/commands/help.rb +63 -0
  30. data/lib/gli/commands/help_modules/command_help_format.rb +134 -0
  31. data/lib/gli/commands/help_modules/global_help_format.rb +61 -0
  32. data/lib/gli/commands/help_modules/list_formatter.rb +22 -0
  33. data/lib/gli/commands/help_modules/options_formatter.rb +50 -0
  34. data/lib/gli/commands/help_modules/text_wrapper.rb +53 -0
  35. data/lib/gli/commands/initconfig.rb +67 -0
  36. data/lib/{support → gli/commands}/scaffold.rb +150 -34
  37. data/lib/gli/dsl.rb +194 -0
  38. data/lib/gli/exceptions.rb +13 -4
  39. data/lib/gli/flag.rb +30 -41
  40. data/lib/gli/gli_option_parser.rb +98 -0
  41. data/lib/gli/option_parser_factory.rb +44 -0
  42. data/lib/gli/options.rb +2 -1
  43. data/lib/gli/switch.rb +19 -51
  44. data/lib/gli/terminal.rb +30 -20
  45. data/lib/gli/version.rb +5 -0
  46. data/test/apps/README.md +2 -0
  47. data/test/apps/todo/Gemfile +2 -0
  48. data/test/apps/todo/README.rdoc +6 -0
  49. data/test/apps/todo/Rakefile +23 -0
  50. data/test/apps/todo/bin/todo +52 -0
  51. data/test/apps/todo/lib/todo/commands/create.rb +22 -0
  52. data/test/apps/todo/lib/todo/commands/list.rb +53 -0
  53. data/test/apps/todo/lib/todo/commands/ls.rb +47 -0
  54. data/test/apps/todo/lib/todo/version.rb +3 -0
  55. data/test/apps/todo/test/tc_nothing.rb +14 -0
  56. data/test/apps/todo/todo.gemspec +23 -0
  57. data/test/apps/todo/todo.rdoc +5 -0
  58. data/test/config.yaml +10 -0
  59. data/test/fake_std_out.rb +30 -0
  60. data/test/gli.reek +122 -0
  61. data/test/init_simplecov.rb +8 -0
  62. data/test/option_test_helper.rb +13 -0
  63. data/test/roodi.yaml +18 -0
  64. data/test/tc_command.rb +260 -0
  65. data/test/tc_compount_command.rb +22 -0
  66. data/test/tc_flag.rb +56 -0
  67. data/test/tc_gli.rb +611 -0
  68. data/test/tc_help.rb +223 -0
  69. data/test/tc_options.rb +31 -0
  70. data/test/tc_subcommands.rb +162 -0
  71. data/test/tc_switch.rb +57 -0
  72. data/test/tc_terminal.rb +97 -0
  73. data/test/test_helper.rb +13 -0
  74. metadata +318 -49
  75. data/lib/gli_version.rb +0 -3
  76. data/lib/support/help.rb +0 -179
  77. data/lib/support/initconfig.rb +0 -34
  78. data/lib/support/rdoc.rb +0 -119
data/README.rdoc CHANGED
@@ -1,11 +1,14 @@
1
1
  = Git-Like Interface Command Line Parser
2
2
 
3
- Author:: Dave Copeland (mailto:davetron5000 at g mail dot com)
4
- Copyright:: Copyright (c) 2010 by Dave Copeland
5
- License:: Distributes under the Apache License, see LICENSE.txt in the source distro
3
+ <b>This describes the forthcoming GLI2 and might not be 100% accurate</b>
6
4
 
7
- This is a DSL you can use to create a command line interface like git, gem or svn, in that the first argument is a command, and there are global and command specific flags.
5
+ The best way to make a "command-suite" command-line application (for the best way to make a
6
+ simpler command-line application, check out methadone[http://www.github.com/davetron5000/methadone]).
8
7
 
8
+ GLI allows you to make a very polished, easy-to-maintain command-line application without a lot
9
+ of syntax, but without restricting you in any way from the power of +OptionParser+.
10
+
11
+ * {Overview}[http://davetron5000.github.com/gli]
9
12
  * {Source on Github}[http://github.com/davetron5000/gli]
10
13
  * RDoc[http://davetron5000.github.com/gli]
11
14
 
@@ -17,17 +20,57 @@ Install if you need to:
17
20
 
18
21
  The simplest way to get started is to create a scaffold project
19
22
 
20
- gli init my_proj command_name other_command_name
23
+ gli init todo list add complete
21
24
 
22
- This will create a basic scaffold project in <tt>./my_proj</tt> with:
25
+ This will create a basic scaffold project in <tt>./todo</tt> with:
23
26
 
24
- * executable in <tt>./my_proj/bin/my_proj</tt>. This file demonstrates most of what you need to describe your command line interface.
25
- * an empty test in <tt>./my_proj/test/tc_nothing.rb</tt> that can bootstrap your tests
27
+ * executable in <tt>./todo/bin/todo</tt>. This file demonstrates most of what you need to describe your command line interface.
28
+ * 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.
26
30
  * a gemspec shell
27
31
  * a README shell
28
32
  * Rakefile that can generate RDoc, package your Gem and run tests
29
33
  * A <tt>Gemfile</tt> suitable for use with Bundler to manage development-time dependencies
30
34
 
35
+ Now, you are ready to go:
36
+
37
+ > cd todo
38
+ > bundle exec bin/todo help
39
+ NAME
40
+ todo - Describe your application here
41
+
42
+ SYNOPSIS
43
+ todo [global options] command [command options] [arguments...]
44
+
45
+ VERSION
46
+ 0.0.1
47
+
48
+ GLOBAL OPTIONS
49
+ -f, --flagname=The name of the argument - Describe some flag here (default: the default)
50
+ --help - Show this message
51
+ -s, --[no-]switch - Describe some switch here
52
+
53
+ COMMANDS
54
+ add - Describe add here
55
+ complete - Describe complete here
56
+ help - Shows a list of commands or help for one command
57
+ list - Describe list here
58
+
59
+ > bundle exec bin/todo help list
60
+ NAME
61
+ list - Describe list here
62
+
63
+ SYNOPSIS
64
+ todo [global options] list [command options] Describe arguments to list here
65
+
66
+ COMMAND OPTIONS
67
+ -f arg - Describe a flag to list (default: default)
68
+ -s - Describe a switch to list
69
+
70
+ All you need to do is fill in the documentation and your code; the help system, command-line parsing and many other awesome features are all handled for you.
71
+
72
+ Get a more detailed walkthrough on the {main site}[http://davetron5000.github.com/gli]
73
+
31
74
  == Supported Platforms
32
75
 
33
76
  Known to work on
@@ -43,7 +86,15 @@ If you're interested in other versions of Ruby, let me know, and I'll add them t
43
86
 
44
87
  == Documentation
45
88
 
46
- Extensive documentation is {available at the wiki}[https://github.com/davetron5000/gli/wiki]. For API Documentation, start with the GLI module.
89
+ Extensive documentation is {available at the wiki}[https://github.com/davetron5000/gli/wiki].
90
+
91
+ API Documentation is available {here}[http://davetron5000.github.com/gli/rdoc/index.html]. Recommend starting with GLI::DSL or GLI::App.
92
+
93
+ == Credits
94
+
95
+ Author:: Dave Copeland (mailto:davetron5000 at g mail dot com)
96
+ Copyright:: Copyright (c) 2010 by Dave Copeland
97
+ License:: Distributes under the Apache License, see LICENSE.txt in the source distro
47
98
 
48
99
  == Links
49
100
 
@@ -52,4 +103,3 @@ Extensive documentation is {available at the wiki}[https://github.com/davetron50
52
103
  * [http://www.github.com/davetron5000/gli/wiki] - Documentation Wiki
53
104
  * [http://www.github.com/davetron5000/gli/wiki/Changelog] - Changelog
54
105
 
55
- :include:gli.rdoc
data/Rakefile ADDED
@@ -0,0 +1,145 @@
1
+ require 'sdoc'
2
+ require 'bundler'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rdoc/task'
6
+ require 'roodi'
7
+ require 'roodi_task'
8
+ require 'cucumber'
9
+ require 'cucumber/rake/task'
10
+
11
+ old_verbose = $VERBOSE
12
+ $VERBOSE=0
13
+ require 'reek/rake/task'
14
+ Reek::Rake::Task.new do |t|
15
+ t.fail_on_error = false
16
+ t.config_files = ['test/gli.reek']
17
+ t.ruby_opts=['-W0']
18
+ t.reek_opts=['-q']
19
+ t.source_files = FileList['lib/**/*.rb'] - ['lib/gli/commands/scaffold.rb','lib/gli/commands/help.rb'] - FileList['lib/gli/commands/help_modules/*.rb']
20
+ end
21
+ $VERBOSE=old_verbose
22
+
23
+ include Rake::DSL
24
+
25
+ CLEAN << "log"
26
+ CLOBBER << FileList['**/*.rbc']
27
+
28
+
29
+ task :rdoc => [:build_rdoc, :hack_css]
30
+ Rake::RDocTask.new(:build_rdoc) do |rd|
31
+ rd.main = "README.rdoc"
32
+ rd.rdoc_files = FileList["lib/**/*.rb","README.rdoc"] -
33
+ FileList["lib/gli/commands/help_modules/*.rb"] -
34
+ ["lib/gli/commands/help.rb",
35
+ "lib/gli/commands/scaffold.rb",
36
+ "lib/gli/support/*.rb",
37
+ "lib/gli/app_support.rb",
38
+ "lib/gli/option_parser_factory.rb",
39
+ "lib/gli/gli_option_parser.rb",
40
+ "lib/gli/command_support.rb",]
41
+ rd.title = 'GLI - Git Like Interface for your command-line apps'
42
+ rd.options << '-f' << 'sdoc'
43
+ rd.template = 'direct'
44
+ end
45
+
46
+ FONT_FIX = {
47
+ "0.82em" => "16px",
48
+ "0.833em" => "16px",
49
+ "0.85em" => "16px",
50
+ "1.15em" => "20px",
51
+ "1.1em" => "20px",
52
+ "1.2em" => "20px",
53
+ "1.4em" => "24px",
54
+ "1.5em" => "24px",
55
+ "1.6em" => "32px",
56
+ "1em" => "16px",
57
+ "2.1em" => "38px",
58
+ }
59
+
60
+
61
+ task :hack_css do
62
+ maincss = File.open('html/css/main.css').readlines
63
+ File.open('html/css/main.css','w') do |file|
64
+ file.puts '@import url(http://fonts.googleapis.com/css?family=Karla:400,700,400italic,700italic|Alegreya);'
65
+
66
+ maincss.each do |line|
67
+ if line.strip == 'font-family: "Helvetica Neue", Arial, sans-serif;'
68
+ file.puts 'font-family: Karla, "Helvetica Neue", Arial, sans-serif;'
69
+ elsif line.strip == 'font-family: monospace;'
70
+ file.puts 'font-family: Monaco, monospace;'
71
+ elsif line =~ /^pre\s*$/
72
+ file.puts "pre {
73
+ font-family: Monaco, monospace;
74
+ margin-bottom: 1em;
75
+ }
76
+ pre.original"
77
+ elsif line =~ /^\s*font-size:\s*(.*)\s*;/
78
+ if FONT_FIX[$1]
79
+ file.puts "font-size: #{FONT_FIX[$1]};"
80
+ else
81
+ file.puts line.chomp
82
+ end
83
+ else
84
+ file.puts line.chomp
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ Bundler::GemHelper.install_tasks
91
+
92
+ RoodiTask.new do |t|
93
+ t.patterns = ['lib/**/*.rb']
94
+ t.config = 'test/roodi.yaml'
95
+ end
96
+
97
+ desc 'run unit tests'
98
+ Rake::TestTask.new do |t|
99
+ t.libs << "test"
100
+ t.test_files = FileList['test/init_simplecov.rb','test/tc_*.rb']
101
+ end
102
+
103
+ CUKE_RESULTS = 'results.html'
104
+ CLEAN << CUKE_RESULTS
105
+ Cucumber::Rake::Task.new(:features) do |t|
106
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
107
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
108
+ t.cucumber_opts = opts
109
+ t.fork = false
110
+ end
111
+ Cucumber::Rake::Task.new('features:wip') do |t|
112
+ tag_opts = ' --tags ~@pending'
113
+ tag_opts = ' --tags @wip'
114
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
115
+ t.fork = false
116
+ end
117
+
118
+ begin
119
+ require 'rcov/rcovtask'
120
+ task :clobber_coverage do
121
+ rm_rf "coverage"
122
+ end
123
+
124
+ desc 'Measures test coverage'
125
+ task :coverage => :rcov do
126
+ puts "coverage/index.html contains what you need"
127
+ end
128
+
129
+ Rcov::RcovTask.new do |t|
130
+ t.libs << 'lib'
131
+ t.test_files = FileList['test/tc_*.rb']
132
+ end
133
+ rescue LoadError
134
+ begin
135
+ require 'simplecov'
136
+ rescue LoadError
137
+ $stderr.puts "neither rcov nor simplecov are installed; you won't be able to check code coverage"
138
+ end
139
+ end
140
+
141
+ desc 'Publish rdoc on github pages and push to github'
142
+ task :publish_rdoc => [:rdoc,:publish]
143
+
144
+ task :default => [:test,:features,:roodi]
145
+
data/bin/gli CHANGED
@@ -1,37 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
- # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
3
- # have this method, so we add it so we get resolved symlinks
4
- # and compatibility
5
- unless File.respond_to? :realpath
6
- class File #:nodoc:
7
- def self.realpath path
8
- return realpath(File.readlink(path)) if symlink?(path)
9
- path
10
- end
11
- end
12
- end
13
-
14
- $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
15
2
 
16
3
  require 'gli'
17
- require 'support/scaffold'
18
- require 'gli_version'
4
+ require 'gli/commands/scaffold'
19
5
 
20
- include GLI
6
+ include GLI::App
21
7
 
22
8
  program_desc 'gli allows you to create the scaffolding for a GLI-powered application'
23
9
 
24
10
  version GLI::VERSION
25
- desc 'Be verbose'
26
- switch :v
27
11
 
28
- desc 'Dry run; don''t change the disk'
29
- switch :n
12
+ switch :v, :desc => 'Be verbose'
13
+
14
+ switch :n, :desc => 'Dry run; don''t change the disk'
30
15
 
31
16
  desc 'Root dir of project'
32
17
  long_desc 'This is the directory where the project''s directory will be made, so if you specify a project name ''foo'' and the root dir of ''.'', the directory ''./foo'' will be created'
33
- default_value '.'
34
- flag [:r,:root]
18
+ flag :r,:root, :default_value => '.'
35
19
 
36
20
  desc 'Create a new GLI-based project'
37
21
  long_desc <<EOS
@@ -43,20 +27,19 @@ EOS
43
27
  arg_name 'project_name [command[ command]*]'
44
28
  command [:init,:scaffold] do |c|
45
29
 
46
- c.desc 'Create an ext dir'
47
- c.switch [:e,:ext]
30
+ c.switch :e,:ext, :desc => 'Create an ext dir'
31
+
32
+ c.switch :notest, :desc => 'Do not create a test or features dir', :negatable => false
48
33
 
49
- c.desc 'Do not create a test dir'
50
- c.switch [:notest]
34
+ c.switch :force, :desc => 'Overwrite/ignore existing files and directories'
51
35
 
52
- c.desc 'Overwrite/ignore existing files and directories'
53
- c.switch [:force]
36
+ c.switch :rvmrc, :desc => 'Create an .rvmrc based on your current RVM setup'
54
37
 
55
38
  c.action do |g,o,args|
56
39
  if args.length < 1
57
40
  raise 'You must specify the name of your project'
58
41
  end
59
- Scaffold.create_scaffold(g[:r],!o[:notest],o[:e],args[0],args[1..-1],o[:force],g[:n])
42
+ GLI::Commands::Scaffold.create_scaffold(g[:r],!o[:notest],o[:e],args[0],args[1..-1],o[:force],g[:n],o[:rvmrc])
60
43
  end
61
44
  end
62
45
 
@@ -68,5 +51,4 @@ end
68
51
  post do |global,command,options,args|
69
52
  puts "Executed #{command.name}" if global[:v]
70
53
  end
71
-
72
54
  exit run(ARGV)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require 'yaml'
3
+ require 'rainbow'
4
+
5
+ results = YAML::load(STDIN)
6
+ success = results["successes"] || []
7
+ errors = results["errors"] || []
8
+ success.each { |ruby| puts ruby.color(:green) }
9
+ errors.each { |ruby| puts ruby.color(:red) }
10
+ exit -1 unless errors.empty?
@@ -0,0 +1,6 @@
1
+ echo tests
2
+ rvm 1.9.2@gli-dev,1.9.3@gli-dev,1.8.7@gli-dev,jruby@gli-dev,rbx@gli-dev,ree@gli-dev --yaml rake test | bin/report_on_rake_results
3
+ rake clobber > /dev/null 2>&1
4
+ echo features
5
+ rvm 1.9.2@gli-dev,1.9.3@gli-dev,1.8.7@gli-dev,jruby@gli-dev,rbx@gli-dev,ree@gli-dev --yaml rake features | bin/report_on_rake_results
6
+ rake clobber > /dev/null 2>&1
@@ -0,0 +1,84 @@
1
+ Feature: The GLI executable works as intended
2
+ As a developer who wants to make a GLI-powered command-line app
3
+ When I use the app provided by GLI
4
+ I get a reasonably working application
5
+
6
+ Background:
7
+ Given I have GLI installed
8
+ And my terminal size is "80x24"
9
+
10
+ Scenario Outline: Getting Help for GLI
11
+ When I run `gli <command>`
12
+ Then the exit status should be 0
13
+ And the output should contain:
14
+ """
15
+ NAME
16
+ gli - gli allows you to create the scaffolding for a GLI-powered application
17
+
18
+ SYNOPSIS
19
+ gli [global options] command [command options] [arguments...]
20
+
21
+ VERSION
22
+ """
23
+ And the output should contain:
24
+ """
25
+ GLOBAL OPTIONS
26
+ --help - Show this message
27
+ -n - Dry run; dont change the disk
28
+ -r, --root=arg - Root dir of project (default: .)
29
+ -v - Be verbose
30
+
31
+ COMMANDS
32
+ help - Shows a list of commands or help for one command
33
+ init, scaffold - Create a new GLI-based project
34
+ """
35
+
36
+ Examples:
37
+ |command|
38
+ | |
39
+ |help |
40
+
41
+
42
+ Scenario Outline: Getting help on scaffolding
43
+ When I run `gli help <command>`
44
+ Then the exit status should be 0
45
+ And the output should contain:
46
+ """
47
+ NAME
48
+ init - Create a new GLI-based project
49
+
50
+ SYNOPSIS
51
+ gli [global options] init [command options] project_name [command[ command]*]
52
+
53
+ DESCRIPTION
54
+ This will create a scaffold command line project that uses GLI for command
55
+ line processing. Specifically, this will create an executable ready to go,
56
+ as well as a lib and test directory, all inside the directory named for your
57
+ project
58
+
59
+ COMMAND OPTIONS
60
+ -e, --[no-]ext - Create an ext dir
61
+ --[no-]force - Overwrite/ignore existing files and directories
62
+ --notest - Do not create a test or features dir
63
+ """
64
+
65
+ Examples:
66
+ |command |
67
+ |init |
68
+ |scaffold |
69
+
70
+
71
+ Scenario: GLI correctly identifies non-existent command
72
+ When I run `gli foobar`
73
+ Then the exit status should not be 0
74
+ And the stderr should contain "error: Unknown command 'foobar'"
75
+
76
+ Scenario: GLI correctly identifies non-existent global flag
77
+ When I run `gli -q help`
78
+ Then the exit status should not be 0
79
+ And the stderr should contain "error: Unknown option -q"
80
+
81
+ Scenario: GLI correctly identifies non-existent command flag
82
+ When I run `gli init -q`
83
+ Then the exit status should not be 0
84
+ And the stderr should contain "error: Unknown option -q"
@@ -0,0 +1,219 @@
1
+ Feature: The scaffold GLI generates works
2
+ As a developer who wants to make a GLI-powered command-line app
3
+ When I generate a GLI-powered app
4
+ Things work out of the box
5
+
6
+ Background:
7
+ Given I have GLI installed
8
+ And GLI's libs are in my path
9
+ And my terminal size is "80x24"
10
+
11
+ Scenario: Scaffold generates and things look good
12
+ When I run `gli init --rvmrc todo add complete list`
13
+ Then the exit status should be 0
14
+ And the output should contain exactly:
15
+ """
16
+ Creating dir ./todo/lib...
17
+ Creating dir ./todo/bin...
18
+ Creating dir ./todo/test...
19
+ Created ./todo/bin/todo
20
+ Created ./todo/README.rdoc
21
+ Created ./todo/todo.rdoc
22
+ Created ./todo/todo.gemspec
23
+ Created ./todo/test/default_test.rb
24
+ Created ./todo/test/test_helper.rb
25
+ Created ./todo/Rakefile
26
+ Created ./todo/Gemfile
27
+ Created ./todo/features
28
+ Created ./todo/lib/todo/version.rb
29
+ Created ./todo/lib/todo.rb
30
+ Created ./todo/.rvmrc
31
+
32
+ """
33
+ And the following directories should exist:
34
+ |todo |
35
+ |todo/bin |
36
+ |todo/test |
37
+ |todo/lib |
38
+ And the following files should exist:
39
+ |todo/bin/todo |
40
+ |todo/README.rdoc |
41
+ |todo/todo.rdoc |
42
+ |todo/todo.gemspec |
43
+ |todo/test/default_test.rb |
44
+ |todo/test/test_helper.rb |
45
+ |todo/Rakefile |
46
+ |todo/Gemfile |
47
+ |todo/lib/todo/version.rb |
48
+ |todo/lib/todo.rb |
49
+ |todo/.rvmrc |
50
+ When I cd to "todo"
51
+ And I make sure todo's lib dir is in my lib path
52
+ And I run `bin/todo`
53
+ Then the output should contain:
54
+ """
55
+ NAME
56
+ todo - Describe your application here
57
+
58
+ SYNOPSIS
59
+ todo [global options] command [command options] [arguments...]
60
+
61
+ VERSION
62
+ 0.0.1
63
+
64
+ GLOBAL OPTIONS
65
+ -f, --flagname=The name of the argument - Describe some flag here (default:
66
+ the default)
67
+ --help - Show this message
68
+ -s, --[no-]switch - Describe some switch here
69
+
70
+ COMMANDS
71
+ add - Describe add here
72
+ complete - Describe complete here
73
+ help - Shows a list of commands or help for one command
74
+ list - Describe list here
75
+
76
+ """
77
+ And I run `bin/todo --help`
78
+ Then the output should contain:
79
+ """
80
+ NAME
81
+ todo - Describe your application here
82
+
83
+ SYNOPSIS
84
+ todo [global options] command [command options] [arguments...]
85
+
86
+ VERSION
87
+ 0.0.1
88
+
89
+ GLOBAL OPTIONS
90
+ -f, --flagname=The name of the argument - Describe some flag here (default:
91
+ the default)
92
+ --help - Show this message
93
+ -s, --[no-]switch - Describe some switch here
94
+
95
+ COMMANDS
96
+ add - Describe add here
97
+ complete - Describe complete here
98
+ help - Shows a list of commands or help for one command
99
+ list - Describe list here
100
+
101
+ """
102
+ When I run `bin/todo help add`
103
+ Then the output should contain:
104
+ """
105
+ NAME
106
+ add - Describe add here
107
+ """
108
+ And the output should contain:
109
+ """
110
+ SYNOPSIS
111
+ todo [global options] add [command options] Describe arguments to add here
112
+ """
113
+ And the output should contain:
114
+ """
115
+ COMMAND OPTIONS
116
+ -f arg - Describe a flag to add (default: default)
117
+ -s - Describe a switch to add
118
+ """
119
+ When I run `rake test`
120
+ Then the output should contain:
121
+ """
122
+ .
123
+ """
124
+ And the output should contain:
125
+ """
126
+
127
+ 1 tests, 1 assertions, 0 failures, 0 errors
128
+ """
129
+ Given todo's libs are no longer in my load path
130
+ When I run `rake features`
131
+ Then the output should contain:
132
+ """
133
+ 1 scenario (1 passed)
134
+ """
135
+ And the output should contain:
136
+ """
137
+ 2 steps (2 passed)
138
+ """
139
+
140
+ Scenario Outline: Scaffold generates and respects flags to create ext dir and avoid test dir
141
+ When I run `<command>`
142
+ Then the exit status should be 0
143
+ And the output should contain exactly:
144
+ """
145
+ Creating dir ./todo/lib...
146
+ Creating dir ./todo/bin...
147
+ Creating dir ./todo/ext...
148
+ Created ./todo/bin/todo
149
+ Created ./todo/README.rdoc
150
+ Created ./todo/todo.rdoc
151
+ Created ./todo/todo.gemspec
152
+ Created ./todo/Rakefile
153
+ Created ./todo/Gemfile
154
+ Created ./todo/lib/todo/version.rb
155
+ Created ./todo/lib/todo.rb
156
+
157
+ """
158
+ And the following directories should exist:
159
+ |todo |
160
+ |todo/bin |
161
+ |todo/ext |
162
+ |todo/lib |
163
+ And the following directories should not exist:
164
+ |todo/test|
165
+ And the following files should exist:
166
+ |todo/bin/todo |
167
+ |todo/README.rdoc |
168
+ |todo/todo.rdoc |
169
+ |todo/todo.gemspec |
170
+ |todo/Rakefile |
171
+ |todo/Gemfile |
172
+ |todo/lib/todo/version.rb |
173
+ |todo/lib/todo.rb |
174
+
175
+ Examples:
176
+ | command |
177
+ | gli init -e --notest todo add complete list |
178
+ | gli init todo add complete list -e --notest |
179
+
180
+ Scenario: Running commands the normal way
181
+ Given I successfully run `gli init todo add complete compute list`
182
+ And I cd to "todo"
183
+ And I make sure todo's lib dir is in my lib path
184
+ When I successfully run `bin/todo add`
185
+ Then the output should contain "add command ran"
186
+ When I successfully run `bin/todo complete`
187
+ Then the output should contain "complete command ran"
188
+ When I run `bin/todo foobar`
189
+ Then the stderr should contain "error: Unknown command 'foobar'"
190
+ And the exit status should not be 0
191
+
192
+ Scenario: Running commands using short form
193
+ Given I successfully run `gli init todo add complete compute list`
194
+ And I cd to "todo"
195
+ And I make sure todo's lib dir is in my lib path
196
+ When I successfully run `bin/todo a`
197
+ Then the output should contain "add command ran"
198
+ When I successfully run `bin/todo l`
199
+ Then the output should contain "list command ran"
200
+ When I successfully run `bin/todo compl`
201
+ Then the output should contain "complete command ran"
202
+
203
+ Scenario: Ambiguous commands give helpful output
204
+ Given I successfully run `gli init todo add complete compute list`
205
+ And I cd to "todo"
206
+ And I make sure todo's lib dir is in my lib path
207
+ When I run `bin/todo comp`
208
+ Then the stderr should contain "Ambiguous command 'comp'. It matches complete,compute"
209
+ And the exit status should not be 0
210
+
211
+ Scenario: Running generated command without bundler gives a helpful error message
212
+ Given I successfully run `gli init todo add complete compute list`
213
+ And I cd to "todo"
214
+ When I run `bin/todo comp`
215
+ Then the exit status should not be 0
216
+ Then the stderr should contain "In development, you need to use `bundle exec bin/todo` to run your app"
217
+ And the stderr should contain "At install-time, RubyGems will make sure lib, etc. are in the load path"
218
+ And the stderr should contain "Feel free to remove this message from bin/todo now"
219
+