cliqr 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +128 -1
  3. data/README.md +97 -71
  4. data/examples/README.md +12 -0
  5. data/examples/hbase +58 -0
  6. data/examples/my-command +63 -0
  7. data/examples/numbers +55 -0
  8. data/examples/vagrant +90 -0
  9. data/lib/cliqr.rb +17 -2
  10. data/lib/cliqr/argument_validation/argument_type_validator.rb +2 -2
  11. data/lib/cliqr/argument_validation/validator.rb +1 -1
  12. data/lib/cliqr/cli/argument_operator.rb +44 -0
  13. data/lib/cliqr/cli/argument_operator_context.rb +20 -0
  14. data/lib/cliqr/cli/command.rb +1 -1
  15. data/lib/cliqr/cli/command_context.rb +93 -12
  16. data/lib/cliqr/cli/command_runner_factory.rb +2 -2
  17. data/lib/cliqr/cli/config.rb +301 -33
  18. data/lib/cliqr/cli/executor.rb +14 -9
  19. data/lib/cliqr/cli/interface.rb +22 -7
  20. data/lib/cliqr/cli/router.rb +6 -2
  21. data/lib/cliqr/cli/shell_command.rb +69 -0
  22. data/lib/cliqr/cli/usage_builder.rb +185 -0
  23. data/lib/cliqr/config_validation/validator_factory.rb +59 -5
  24. data/lib/cliqr/error.rb +10 -4
  25. data/lib/cliqr/parser/action_token.rb +23 -0
  26. data/lib/cliqr/parser/argument_parser.rb +1 -1
  27. data/lib/cliqr/parser/argument_token.rb +1 -4
  28. data/lib/cliqr/parser/argument_tree_walker.rb +40 -8
  29. data/lib/cliqr/parser/option_token.rb +2 -1
  30. data/lib/cliqr/parser/parsed_input.rb +21 -2
  31. data/lib/cliqr/parser/parsed_input_builder.rb +11 -7
  32. data/lib/cliqr/parser/token.rb +3 -9
  33. data/lib/cliqr/parser/token_factory.rb +1 -1
  34. data/lib/cliqr/util.rb +135 -0
  35. data/lib/cliqr/version.rb +1 -1
  36. data/spec/argument_parser_spec_helper.rb +15 -0
  37. data/spec/config/action_config_validator_spec.rb +146 -0
  38. data/spec/config/config_finalize_spec.rb +1 -1
  39. data/spec/config/config_validator_spec.rb +29 -19
  40. data/spec/config/option_config_validator_spec.rb +13 -13
  41. data/spec/dsl/interface_spec.rb +1 -168
  42. data/spec/dsl/usage_spec.rb +705 -0
  43. data/spec/executor/action_executor_spec.rb +205 -0
  44. data/spec/executor/executor_spec.rb +405 -17
  45. data/spec/executor/help_executor_spec.rb +424 -0
  46. data/spec/executor/shell_executor_spec.rb +233 -0
  47. data/spec/fixtures/action_reader_command.rb +12 -0
  48. data/spec/fixtures/csv_argument_operator.rb +8 -0
  49. data/spec/fixtures/test_option_type_checker_command.rb +8 -0
  50. data/spec/parser/action_argument_parser_spec.rb +113 -0
  51. data/spec/parser/argument_parser_spec.rb +37 -44
  52. data/spec/spec_helper.rb +1 -0
  53. data/spec/validation/action_argument_validator_spec.rb +50 -0
  54. data/spec/validation/{argument_validation_spec.rb → command_argument_validation_spec.rb} +36 -18
  55. data/spec/validation/error_spec.rb +1 -1
  56. data/tasks/rdoc.rake +16 -0
  57. data/tasks/rubucop.rake +14 -0
  58. data/tasks/yard.rake +21 -0
  59. data/templates/usage.erb +39 -0
  60. metadata +48 -11
@@ -13,7 +13,7 @@ Cause: NoMethodError - undefined method `non_existent' for {}:Hash
13
13
  begin
14
14
  {}.non_existent
15
15
  rescue StandardError => e
16
- raise Cliqr::Error::CommandRuntimeException.new('something went wrong', e)
16
+ raise Cliqr::Error::CommandRuntimeError.new('something went wrong', e)
17
17
  end
18
18
  rescue Cliqr::Error::CliqrError => e
19
19
  expect(e.to_s).to eq(expected_error_message)
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require 'rdoc/task'
5
+
6
+ RDoc::Task.new do |rdoc|
7
+ rdoc.rdoc_dir = '.doc/rdoc'
8
+ rdoc.title = "cliqr #{Cliqr::VERSION}"
9
+ rdoc.main = 'README.md'
10
+ rdoc.rdoc_files.include('README.md', 'LICENSE.txt', 'CHANGELOG.md', 'lib/**/*.rb')
11
+ end
12
+ CLEAN.include('.doc')
13
+ CLEAN.include('doc')
14
+ rescue LoadError
15
+ # do nothing
16
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require 'rubocop/rake_task'
5
+
6
+ desc 'Run RuboCop on the lib directory'
7
+ RuboCop::RakeTask.new(:rubocop) do |task|
8
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
9
+ # abort rake on failure
10
+ task.fail_on_error = true
11
+ end
12
+ rescue
13
+ # do nothing
14
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require 'yardstick/rake/measurement'
5
+ require 'yardstick/rake/verify'
6
+
7
+ # yardstick_measure task
8
+ Yardstick::Rake::Measurement.new do |measurement|
9
+ measurement.output = '.metrics/yard-report.txt'
10
+ end
11
+ CLEAN.include('.metrics')
12
+ CLEAN.include('.yardoc')
13
+
14
+ # verify_measurements task
15
+ Yardstick::Rake::Verify.new do |verify|
16
+ verify.threshold = 100
17
+ verify.require_exact_threshold = false
18
+ end
19
+ rescue LoadError
20
+ # do nothing
21
+ end
@@ -0,0 +1,39 @@
1
+ <%= command %><% unless description.nil? || description.empty? %> -- <%= description %><% end %>
2
+
3
+ USAGE:
4
+ <%= command %><%=
5
+ ' [actions]' if actions? %><%=
6
+ ' [options]' if options? %><%=
7
+ ' [arguments]' if arguments? %><%
8
+
9
+ if options? %>
10
+
11
+ Available options:
12
+ <%
13
+ options.each { |option|
14
+ %>
15
+ --<%=
16
+ '[no-]' if option.boolean?
17
+ %><%=
18
+ option.name
19
+ %><%=
20
+ ", -#{option.short}" if option.short?
21
+ %><%=
22
+ if option.details?
23
+ " : #{" <#{option.type}>" if option.type?}#{" #{option.description}" if option.description?}#{" (default => #{option.default.inspect})" if option.default?}"
24
+ end
25
+ %><%
26
+ }
27
+ end
28
+
29
+ if actions? %>
30
+
31
+ Available actions:
32
+ <%= "[ Type \"#{command} help [action-name]\" to get more information about that action ]\n" if help? %><%
33
+ actions.each { |action|
34
+ %>
35
+ <%= action.name %><%= " -- #{action.description}" if action.description? %>
36
+ <%
37
+ }
38
+ %>
39
+ <% end %>
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliqr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anshul Verma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log4r
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  description: |2
@@ -54,10 +54,17 @@ files:
54
54
  - LICENSE.txt
55
55
  - README.md
56
56
  - Rakefile
57
+ - examples/README.md
58
+ - examples/hbase
59
+ - examples/my-command
60
+ - examples/numbers
61
+ - examples/vagrant
57
62
  - lib/cliqr.rb
58
63
  - lib/cliqr/argument_validation/argument_type_validator.rb
59
64
  - lib/cliqr/argument_validation/option_validator.rb
60
65
  - lib/cliqr/argument_validation/validator.rb
66
+ - lib/cliqr/cli/argument_operator.rb
67
+ - lib/cliqr/cli/argument_operator_context.rb
61
68
  - lib/cliqr/cli/command.rb
62
69
  - lib/cliqr/cli/command_context.rb
63
70
  - lib/cliqr/cli/command_runner_factory.rb
@@ -65,11 +72,14 @@ files:
65
72
  - lib/cliqr/cli/executor.rb
66
73
  - lib/cliqr/cli/interface.rb
67
74
  - lib/cliqr/cli/router.rb
75
+ - lib/cliqr/cli/shell_command.rb
76
+ - lib/cliqr/cli/usage_builder.rb
68
77
  - lib/cliqr/config_validation/validation_set.rb
69
78
  - lib/cliqr/config_validation/validator_factory.rb
70
79
  - lib/cliqr/config_validation/verifiable.rb
71
80
  - lib/cliqr/dsl.rb
72
81
  - lib/cliqr/error.rb
82
+ - lib/cliqr/parser/action_token.rb
73
83
  - lib/cliqr/parser/argument_parser.rb
74
84
  - lib/cliqr/parser/argument_token.rb
75
85
  - lib/cliqr/parser/argument_tree_walker.rb
@@ -80,25 +90,41 @@ files:
80
90
  - lib/cliqr/parser/single_valued_option_token.rb
81
91
  - lib/cliqr/parser/token.rb
82
92
  - lib/cliqr/parser/token_factory.rb
93
+ - lib/cliqr/util.rb
83
94
  - lib/cliqr/validation_errors.rb
84
95
  - lib/cliqr/version.rb
96
+ - spec/argument_parser_spec_helper.rb
97
+ - spec/config/action_config_validator_spec.rb
85
98
  - spec/config/config_finalize_spec.rb
86
99
  - spec/config/config_validator_spec.rb
87
100
  - spec/config/option_config_validator_spec.rb
88
101
  - spec/dsl/interface_spec.rb
102
+ - spec/dsl/usage_spec.rb
103
+ - spec/executor/action_executor_spec.rb
89
104
  - spec/executor/command_runner_spec.rb
90
105
  - spec/executor/executor_spec.rb
106
+ - spec/executor/help_executor_spec.rb
107
+ - spec/executor/shell_executor_spec.rb
108
+ - spec/fixtures/action_reader_command.rb
91
109
  - spec/fixtures/always_error_command.rb
92
110
  - spec/fixtures/argument_reader_command.rb
111
+ - spec/fixtures/csv_argument_operator.rb
93
112
  - spec/fixtures/option_reader_command.rb
94
113
  - spec/fixtures/test_command.rb
95
114
  - spec/fixtures/test_option_checker_command.rb
96
115
  - spec/fixtures/test_option_reader_command.rb
116
+ - spec/fixtures/test_option_type_checker_command.rb
117
+ - spec/parser/action_argument_parser_spec.rb
97
118
  - spec/parser/argument_parser_spec.rb
98
119
  - spec/spec_helper.rb
99
- - spec/validation/argument_validation_spec.rb
120
+ - spec/validation/action_argument_validator_spec.rb
121
+ - spec/validation/command_argument_validation_spec.rb
100
122
  - spec/validation/error_spec.rb
101
123
  - spec/validation/validation_spec.rb
124
+ - tasks/rdoc.rake
125
+ - tasks/rubucop.rake
126
+ - tasks/yard.rake
127
+ - templates/usage.erb
102
128
  homepage: https://github.com/anshulverma/cliqr
103
129
  licenses:
104
130
  - MIT
@@ -109,36 +135,47 @@ require_paths:
109
135
  - lib
110
136
  required_ruby_version: !ruby/object:Gem::Requirement
111
137
  requirements:
112
- - - '>='
138
+ - - ">="
113
139
  - !ruby/object:Gem::Version
114
140
  version: 1.9.3
115
141
  required_rubygems_version: !ruby/object:Gem::Requirement
116
142
  requirements:
117
- - - '>='
143
+ - - ">="
118
144
  - !ruby/object:Gem::Version
119
145
  version: 1.3.6
120
146
  requirements: []
121
147
  rubyforge_project:
122
- rubygems_version: 2.4.6
148
+ rubygems_version: 2.2.2
123
149
  signing_key:
124
150
  specification_version: 4
125
151
  summary: A framework and DSL for defining CLI interface
126
152
  test_files:
153
+ - spec/argument_parser_spec_helper.rb
154
+ - spec/config/action_config_validator_spec.rb
127
155
  - spec/config/config_finalize_spec.rb
128
156
  - spec/config/config_validator_spec.rb
129
157
  - spec/config/option_config_validator_spec.rb
130
158
  - spec/dsl/interface_spec.rb
159
+ - spec/dsl/usage_spec.rb
160
+ - spec/executor/action_executor_spec.rb
131
161
  - spec/executor/command_runner_spec.rb
132
162
  - spec/executor/executor_spec.rb
163
+ - spec/executor/help_executor_spec.rb
164
+ - spec/executor/shell_executor_spec.rb
165
+ - spec/fixtures/action_reader_command.rb
133
166
  - spec/fixtures/always_error_command.rb
134
167
  - spec/fixtures/argument_reader_command.rb
168
+ - spec/fixtures/csv_argument_operator.rb
135
169
  - spec/fixtures/option_reader_command.rb
136
170
  - spec/fixtures/test_command.rb
137
171
  - spec/fixtures/test_option_checker_command.rb
138
172
  - spec/fixtures/test_option_reader_command.rb
173
+ - spec/fixtures/test_option_type_checker_command.rb
174
+ - spec/parser/action_argument_parser_spec.rb
139
175
  - spec/parser/argument_parser_spec.rb
140
176
  - spec/spec_helper.rb
141
- - spec/validation/argument_validation_spec.rb
177
+ - spec/validation/action_argument_validator_spec.rb
178
+ - spec/validation/command_argument_validation_spec.rb
142
179
  - spec/validation/error_spec.rb
143
180
  - spec/validation/validation_spec.rb
144
181
  has_rdoc: