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,109 @@
1
+ = Git-Like Interface Command Line Parser
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+.
8
+
9
+ * {Overview}[http://davetron5000.github.com/gli]
10
+ * {Source on Github}[http://github.com/davetron5000/gli]
11
+ * RDoc[http://davetron5000.github.com/gli/rdoc/index.html]
12
+
13
+ {<img src="https://secure.travis-ci.org/davetron5000/gli.png?branch=gli-2" alt="Build Status" />}[https://travis-ci.org/davetron5000/gli]
14
+
15
+ == Use
16
+
17
+ Install if you need to:
18
+
19
+ gem install gli
20
+
21
+ The simplest way to get started is to create a scaffold project
22
+
23
+ gli init todo list add complete
24
+
25
+ This will create a basic scaffold project in <tt>./todo</tt> with:
26
+
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.
30
+ * a gemspec shell
31
+ * a README shell
32
+ * Rakefile that can generate RDoc, package your Gem and run tests
33
+ * A <tt>Gemfile</tt> suitable for use with Bundler to manage development-time dependencies
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
+
74
+ == Supported Platforms
75
+
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
85
+
86
+ If you're interested in other versions of Ruby, let me know, and I'll add them to my test suite
87
+
88
+ == Documentation
89
+
90
+ Extensive documentation is {available at the wiki}[https://github.com/davetron5000/gli/wiki].
91
+
92
+ API Documentation is available {here}[http://davetron5000.github.com/gli/rdoc/index.html]. Recommend starting with GLI::DSL or GLI::App.
93
+
94
+ == Credits
95
+
96
+ Author:: Dave Copeland (mailto:davetron5000 at g mail dot com)
97
+ Copyright:: Copyright (c) 2010 by Dave Copeland
98
+ License:: Distributes under the Apache License, see LICENSE.txt in the source distro
99
+
100
+ == Links
101
+
102
+ * [http://davetron5000.github.com/gli] - RubyDoc
103
+ * [http://www.github.com/davetron5000/gli] - Source on GitHub
104
+ * [http://www.github.com/davetron5000/gli/wiki] - Documentation Wiki
105
+ * [http://www.github.com/davetron5000/gli/wiki/Changelog] - Changelog
106
+
107
+ = <code>gli</code> CLI documentation
108
+
109
+ :include:gli.rdoc
@@ -0,0 +1,126 @@
1
+ require 'sdoc'
2
+ require 'bundler'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rdoc/task'
6
+ require 'cucumber'
7
+ require 'cucumber/rake/task'
8
+
9
+ include Rake::DSL
10
+
11
+ CLEAN << "log"
12
+ CLOBBER << FileList['**/*.rbc']
13
+
14
+
15
+ task :rdoc => [:build_rdoc, :hack_css]
16
+ Rake::RDocTask.new(:build_rdoc) do |rd|
17
+ rd.main = "README.rdoc"
18
+ rd.rdoc_files = FileList["lib/**/*.rb","README.rdoc"] -
19
+ FileList["lib/gli/commands/help_modules/*.rb"] -
20
+ ["lib/gli/commands/help.rb",
21
+ "lib/gli/commands/scaffold.rb",
22
+ "lib/gli/support/*.rb",
23
+ "lib/gli/app_support.rb",
24
+ "lib/gli/option_parser_factory.rb",
25
+ "lib/gli/gli_option_parser.rb",
26
+ "lib/gli/command_support.rb",]
27
+ rd.title = 'GLI - Git Like Interface for your command-line apps'
28
+ rd.options << '-f' << 'sdoc'
29
+ rd.template = 'direct'
30
+ end
31
+
32
+ FONT_FIX = {
33
+ "0.82em" => "16px",
34
+ "0.833em" => "16px",
35
+ "0.85em" => "16px",
36
+ "1.15em" => "20px",
37
+ "1.1em" => "20px",
38
+ "1.2em" => "20px",
39
+ "1.4em" => "24px",
40
+ "1.5em" => "24px",
41
+ "1.6em" => "32px",
42
+ "1em" => "16px",
43
+ "2.1em" => "38px",
44
+ }
45
+
46
+
47
+ task :hack_css do
48
+ maincss = File.open('html/css/main.css').readlines
49
+ File.open('html/css/main.css','w') do |file|
50
+ file.puts '@import url(http://fonts.googleapis.com/css?family=Karla:400,700,400italic,700italic|Alegreya);'
51
+
52
+ maincss.each do |line|
53
+ if line.strip == 'font-family: "Helvetica Neue", Arial, sans-serif;'
54
+ file.puts 'font-family: Karla, "Helvetica Neue", Arial, sans-serif;'
55
+ elsif line.strip == 'font-family: monospace;'
56
+ file.puts 'font-family: Monaco, monospace;'
57
+ elsif line =~ /^pre\s*$/
58
+ file.puts "pre {
59
+ font-family: Monaco, monospace;
60
+ margin-bottom: 1em;
61
+ }
62
+ pre.original"
63
+ elsif line =~ /^\s*font-size:\s*(.*)\s*;/
64
+ if FONT_FIX[$1]
65
+ file.puts "font-size: #{FONT_FIX[$1]};"
66
+ else
67
+ file.puts line.chomp
68
+ end
69
+ else
70
+ file.puts line.chomp
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ Bundler::GemHelper.install_tasks
77
+
78
+ desc 'run unit tests'
79
+ Rake::TestTask.new do |t|
80
+ t.libs << "test"
81
+ t.test_files = FileList['test/init_simplecov.rb','test/tc_*.rb']
82
+ end
83
+
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"
103
+ end
104
+
105
+ desc 'Measures test coverage'
106
+ task :coverage => :rcov do
107
+ puts "coverage/index.html contains what you need"
108
+ end
109
+
110
+ Rcov::RcovTask.new do |t|
111
+ t.libs << 'lib'
112
+ t.test_files = FileList['test/tc_*.rb']
113
+ end
114
+ 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
+ end
121
+
122
+ desc 'Publish rdoc on github pages and push to github'
123
+ task :publish_rdoc => [:rdoc,:publish]
124
+
125
+ task :default => [:test,:features]
126
+
data/bin/gli ADDED
@@ -0,0 +1,59 @@
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])
48
+ end
49
+ end
50
+
51
+ pre do |global,command,options,args|
52
+ puts "Executing #{command.name}" if global[:v]
53
+ true
54
+ end
55
+
56
+ post do |global,command,options,args|
57
+ puts "Executed #{command.name}" if global[:v]
58
+ end
59
+ 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,90 @@
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 - create 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
+ --version - Display the program version
31
+
32
+ COMMANDS
33
+ help - Shows a list of commands or help for one command
34
+ init, scaffold - Create a new GLI-based project
35
+ """
36
+
37
+ Examples:
38
+ |command|
39
+ | |
40
+ |help |
41
+
42
+
43
+ Scenario Outline: Getting help on scaffolding
44
+ When I run `gli help <command>`
45
+ Then the exit status should be 0
46
+ And the output should contain:
47
+ """
48
+ NAME
49
+ init - Create a new GLI-based project
50
+
51
+ SYNOPSIS
52
+ gli [global options] init [command options] project_name [command[ command]*]
53
+
54
+ DESCRIPTION
55
+ This will create a scaffold command line project that uses GLI for command
56
+ line processing. Specifically, this will create an executable ready to go,
57
+ as well as a lib and test directory, all inside the directory named for your
58
+ project
59
+
60
+ COMMAND OPTIONS
61
+ -e, --[no-]ext - Create an ext dir
62
+ --[no-]force - Overwrite/ignore existing files and directories
63
+ --notest - Do not create a test or features dir
64
+ """
65
+
66
+ Examples:
67
+ |command |
68
+ |init |
69
+ |scaffold |
70
+
71
+
72
+ Scenario: GLI correctly identifies non-existent command
73
+ When I run `gli foobar`
74
+ Then the exit status should not be 0
75
+ And the stderr should contain "error: Unknown command 'foobar'"
76
+
77
+ Scenario: GLI correctly identifies non-existent global flag
78
+ When I run `gli -q help`
79
+ Then the exit status should not be 0
80
+ And the stderr should contain "error: Unknown option -q"
81
+
82
+ Scenario: GLI correctly identifies non-existent command flag
83
+ When I run `gli init -q`
84
+ Then the exit status should not be 0
85
+ And the stderr should contain "error: Unknown option -q"
86
+
87
+ Scenario: The _doc command doesn't blow up
88
+ Given the file "gli.rdoc" doesn't exist
89
+ When I run `gli _doc`
90
+ Then a file named "gli.rdoc" should exist
@@ -0,0 +1,232 @@
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
+ --version - Display the program version
70
+
71
+ COMMANDS
72
+ add - Describe add here
73
+ complete - Describe complete here
74
+ help - Shows a list of commands or help for one command
75
+ list - Describe list here
76
+
77
+ """
78
+ And I run `bin/todo --help`
79
+ Then the output should contain:
80
+ """
81
+ NAME
82
+ todo - Describe your application here
83
+
84
+ SYNOPSIS
85
+ todo [global options] command [command options] [arguments...]
86
+
87
+ VERSION
88
+ 0.0.1
89
+
90
+ GLOBAL OPTIONS
91
+ -f, --flagname=The name of the argument - Describe some flag here (default:
92
+ the default)
93
+ --help - Show this message
94
+ -s, --[no-]switch - Describe some switch here
95
+ --version - Display the program version
96
+
97
+ COMMANDS
98
+ add - Describe add here
99
+ complete - Describe complete here
100
+ help - Shows a list of commands or help for one command
101
+ list - Describe list here
102
+
103
+ """
104
+ When I run `bin/todo help add`
105
+ Then the output should contain:
106
+ """
107
+ NAME
108
+ add - Describe add here
109
+ """
110
+ And the output should contain:
111
+ """
112
+ SYNOPSIS
113
+ todo [global options] add [command options] Describe arguments to add here
114
+ """
115
+ And the output should contain:
116
+ """
117
+ COMMAND OPTIONS
118
+ -f arg - Describe a flag to add (default: default)
119
+ -s - Describe a switch to add
120
+ """
121
+ When I run `rake test`
122
+ Then the output should contain:
123
+ """
124
+ .
125
+ """
126
+ And the output should contain:
127
+ """
128
+
129
+ 1 tests, 1 assertions, 0 failures, 0 errors
130
+ """
131
+ Given todo's libs are no longer in my load path
132
+ When I run `rake features`
133
+ Then the output should contain:
134
+ """
135
+ 1 scenario (1 passed)
136
+ """
137
+ And the output should contain:
138
+ """
139
+ 2 steps (2 passed)
140
+ """
141
+
142
+ Scenario Outline: Scaffold generates and respects flags to create ext dir and avoid test dir
143
+ When I run `<command>`
144
+ Then the exit status should be 0
145
+ And the output should contain exactly:
146
+ """
147
+ Creating dir ./todo/lib...
148
+ Creating dir ./todo/bin...
149
+ Creating dir ./todo/ext...
150
+ Created ./todo/bin/todo
151
+ Created ./todo/README.rdoc
152
+ Created ./todo/todo.rdoc
153
+ Created ./todo/todo.gemspec
154
+ Created ./todo/Rakefile
155
+ Created ./todo/Gemfile
156
+ Created ./todo/lib/todo/version.rb
157
+ Created ./todo/lib/todo.rb
158
+
159
+ """
160
+ And the following directories should exist:
161
+ |todo |
162
+ |todo/bin |
163
+ |todo/ext |
164
+ |todo/lib |
165
+ And the following directories should not exist:
166
+ |todo/test|
167
+ And the following files should exist:
168
+ |todo/bin/todo |
169
+ |todo/README.rdoc |
170
+ |todo/todo.rdoc |
171
+ |todo/todo.gemspec |
172
+ |todo/Rakefile |
173
+ |todo/Gemfile |
174
+ |todo/lib/todo/version.rb |
175
+ |todo/lib/todo.rb |
176
+
177
+ Examples:
178
+ | command |
179
+ | gli init -e --notest todo add complete list |
180
+ | gli init todo add complete list -e --notest |
181
+
182
+ Scenario: Running commands the normal way
183
+ Given I successfully run `gli init todo add complete compute list`
184
+ And I cd to "todo"
185
+ And I make sure todo's lib dir is in my lib path
186
+ When I successfully run `bin/todo add`
187
+ Then the output should contain "add command ran"
188
+ When I successfully run `bin/todo complete`
189
+ Then the output should contain "complete command ran"
190
+ When I run `bin/todo foobar`
191
+ Then the stderr should contain "error: Unknown command 'foobar'"
192
+ And the exit status should not be 0
193
+
194
+ Scenario: Running commands using short form
195
+ Given I successfully run `gli init todo add complete compute list`
196
+ And I cd to "todo"
197
+ And I make sure todo's lib dir is in my lib path
198
+ When I successfully run `bin/todo a`
199
+ Then the output should contain "add command ran"
200
+ When I successfully run `bin/todo l`
201
+ Then the output should contain "list command ran"
202
+ When I successfully run `bin/todo compl`
203
+ Then the output should contain "complete command ran"
204
+
205
+ Scenario: Ambiguous commands give helpful output
206
+ Given I successfully run `gli init todo add complete compute list`
207
+ And I cd to "todo"
208
+ And I make sure todo's lib dir is in my lib path
209
+ When I run `bin/todo comp`
210
+ Then the stderr should contain "Ambiguous command 'comp'. It matches complete,compute"
211
+ And the exit status should not be 0
212
+
213
+ Scenario: Running generated command without bundler gives a helpful error message
214
+ Given I successfully run `gli init todo add complete compute list`
215
+ And I cd to "todo"
216
+ When I run `bin/todo comp`
217
+ Then the exit status should not be 0
218
+ Then the stderr should contain "In development, you need to use `bundle exec bin/todo` to run your app"
219
+ And the stderr should contain "At install-time, RubyGems will make sure lib, etc. are in the load path"
220
+ And the stderr should contain "Feel free to remove this message from bin/todo now"
221
+
222
+ Scenario: Running commands with a dash in the name
223
+ Given I successfully run `gli init todo-app add complete compute list`
224
+ And I cd to "todo-app"
225
+ And I make sure todo's lib dir is in my lib path
226
+ When I successfully run `bin/todo-app add`
227
+ Then the output should contain "add command ran"
228
+ When I successfully run `bin/todo-app complete`
229
+ Then the output should contain "complete command ran"
230
+ When I run `bin/todo-app foobar`
231
+ Then the stderr should contain "error: Unknown command 'foobar'"
232
+ And the exit status should not be 0