cri 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWExM2ZhMjgwODJmMmVhMGU5ZTg2YTQzN2EwYTgwYjI2NzM3MzRhYw==
4
+ NmEyNjRhYjcyOTg2MzdiNWM1MDA5OWJiYTM0ZWNiMGIzYWM1ZjAxNw==
5
5
  data.tar.gz: !binary |-
6
- NTJjOWQ4ZDZjOGEzZmUzMDg4ZGQ4NzIyMWQ4NDQ5MTcyZjI4NWNkOA==
7
- !binary "U0hBNTEy":
6
+ MGUyZjJjNjdkMGY2ZjAxYWZjYzdjMzgzMTAzOWZiMzgwZWYzYTkzOA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- YjU3YTNjYWMyZDI3ZTM5Y2FkMGY1NDQ4YTcxYWU1YWNlYmEwNDg1YWE2ODhi
10
- OGNhZjdiOGMyZGQ2MzUwOWZjMmQxNDVjYjAyYWM3ZTFhYjE4NzEwNzUzYjk4
11
- N2RlMDdkM2IzYWU4MGRhNDExMTFkZmY5NWYzYWNhNmM1OTgzMGE=
9
+ MjhlMjE2ODU5OTNiODMxZTY4ZGFlMzA3YjM0OGY3MDRiYmI2MzUwMjNhMTY1
10
+ YmY2YTZkODk2NGEyNjYwMmZiOTM0ZjQ2ZDQ3YWE5NDIxMWNkZGZhY2UzNjVk
11
+ MmJmNDI0ZjYwMDQ5ODYyNzE4N2QwNjQ3NzVlMTJmZmZlZTFlODg=
12
12
  data.tar.gz: !binary |-
13
- NjUzMWY0NjY2ZTU5ZmE3ZGZjMWMzMjQ0OGE2ZGRlMzFkOTE4NTIyODcwNDU4
14
- MTkyZGRlMjNmNmY1MzVmMmJlNzVhZmQ0N2E2ZmYyMjcxYmU2M2NhYzVhMWU2
15
- MmI1ZGQyNWQ0NjU1ZmU0NDEzNjdhMjA0ZTEwMjFkYTM4YTQ0MDg=
13
+ OGZjNzRmYzk5ZmYzMmVhZDlhOTcyM2IzOGY2OTZhOWQ5YmFmMzdjODZmYzk2
14
+ MjhmMDkzOTQ3Yjc2Mzc4MjExMTg4ZjU4ZTM5N2YzNTgwZWViMTgxZTdjZjJl
15
+ NTYxYWJjOGE5ZDM2MWY3NzQ2M2FjYWU0NjEyNGY3YmZmOGQ5MmI=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cri (2.4.0)
4
+ cri (2.4.1)
5
5
  colored (>= 1.2)
6
6
 
7
7
  GEM
data/NEWS.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Cri News
2
2
  ========
3
3
 
4
+ 2.4.1
5
+ -----
6
+
7
+ * Fixed ordering of option groups on Ruby 1.8.x (#14, #15)
8
+ * Fixed ordering of commands when --verbose is passed (#16, #18)
9
+
4
10
  2.4.0
5
11
  -----
6
12
 
data/cri.gemspec CHANGED
@@ -9,13 +9,14 @@ Gem::Specification.new do |s|
9
9
  s.homepage = 'http://stoneship.org/software/cri/' # TODO CREATE A WEB SITE YOU SILLY PERSON
10
10
  s.summary = 'a library for building easy-to-use commandline tools'
11
11
  s.description = 'Cri allows building easy-to-use commandline interfaces with support for subcommands.'
12
+ s.license = 'MIT'
12
13
 
13
14
  s.author = 'Denis Defreyne'
14
15
  s.email = 'denis.defreyne@stoneship.org'
15
16
 
16
17
  s.files = Dir['[A-Z]*'] +
17
18
  Dir['{lib,test}/**/*'] +
18
- [ 'cri.gemspec', '.gemtest' ]
19
+ [ 'cri.gemspec' ]
19
20
  s.require_paths = [ 'lib' ]
20
21
 
21
22
  s.add_dependency('colored', '>= 1.2')
@@ -25,5 +26,5 @@ Gem::Specification.new do |s|
25
26
  s.add_development_dependency('yard')
26
27
 
27
28
  s.rdoc_options = [ '--main', 'README.md' ]
28
- s.extra_rdoc_files = [ 'ChangeLog', 'LICENSE', 'README.md', 'NEWS.md' ]
29
+ s.extra_rdoc_files = [ 'LICENSE', 'README.md', 'NEWS.md' ]
29
30
  end
data/lib/cri/command.rb CHANGED
@@ -90,7 +90,9 @@ module Cri
90
90
  # context with the command DSL as its parameter. If the block has no
91
91
  # parameters, the block will be executed in the context of the DSL.
92
92
  #
93
- # @param [String, nil] The string containing the command’s definition
93
+ # @param [String, nil] string The command definition as a string
94
+ #
95
+ # @param [String, nil] filename The filename corresponding to the string parameter (only useful if a string is given)
94
96
  #
95
97
  # @return [Cri::Command] The newly defined command
96
98
  def self.define(string=nil, filename=nil, &block)
@@ -336,32 +338,25 @@ module Cri
336
338
  text << (self.supercommand ? 'subcommands' : 'commands').formatted_as_title
337
339
  text << "\n"
338
340
 
339
- visible_cmds, invisible_cmds = self.subcommands.partition { |c| !c.hidden? }
340
-
341
- commands_for_length = is_verbose ? self.subcommands : visible_cmds
342
- length = commands_for_length.map { |c| c.name.formatted_as_command.size }.max
341
+ shown_subcommands = self.subcommands.select { |c| !c.hidden? || is_verbose }
342
+ length = shown_subcommands.map { |c| c.name.formatted_as_command.size }.max
343
343
 
344
- # Visible
345
- visible_cmds.sort_by { |cmd| cmd.name }.each do |cmd|
344
+ # Command
345
+ shown_subcommands.sort_by { |cmd| cmd.name }.each do |cmd|
346
346
  text << sprintf(" %-#{length+4}s %s\n",
347
347
  cmd.name.formatted_as_command,
348
348
  cmd.summary)
349
349
  end
350
350
 
351
- # Invisible
352
- if is_verbose
353
- invisible_cmds.sort_by { |cmd| cmd.name }.each do |cmd|
354
- text << sprintf(" %-#{length+4}s %s\n",
355
- cmd.name.formatted_as_command,
356
- cmd.summary)
357
- end
358
- else
359
- case invisible_cmds.size
351
+ # Hidden notice
352
+ if !is_verbose
353
+ diff = self.subcommands.size - shown_subcommands.size
354
+ case diff
360
355
  when 0
361
356
  when 1
362
- text << " (1 hidden command ommitted; show it with --verbose)\n"
357
+ text << " (1 hidden command omitted; show it with --verbose)\n"
363
358
  else
364
- text << " (#{invisible_cmds.size} hidden commands ommitted; show them with --verbose)\n"
359
+ text << " (#{diff} hidden commands omitted; show them with --verbose)\n"
365
360
  end
366
361
  end
367
362
  end
@@ -372,7 +367,8 @@ module Cri
372
367
  groups["options for #{self.supercommand.name}"] = self.supercommand.global_option_definitions
373
368
  end
374
369
  length = groups.values.inject(&:+).map { |o| o[:long].to_s.size }.max
375
- groups.each_pair do |name, defs|
370
+ groups.keys.sort.each do |name|
371
+ defs = groups[name]
376
372
  unless defs.empty?
377
373
  text << "\n"
378
374
  text << "#{name}".formatted_as_title
data/lib/cri/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Cri
2
2
 
3
3
  # The current Cri version.
4
- VERSION = '2.4.0'
4
+ VERSION = '2.4.1'
5
5
 
6
6
  end
data/test/test_command.rb CHANGED
@@ -276,6 +276,12 @@ class Cri::CommandTestCase < Cri::TestCase
276
276
  assert_match(/^\e\[33m -s \e\[0mshort$/, help)
277
277
  end
278
278
 
279
+ def test_help_with_multiple_groups
280
+ help = nested_cmd.subcommands.find { |cmd| cmd.name == 'sub' }.help
281
+
282
+ assert_match(/OPTIONS.*OPTIONS FOR SUPER/m, help)
283
+ end
284
+
279
285
  def test_modify_with_block_argument
280
286
  cmd = Cri::Command.define do |c|
281
287
  c.name 'build'
@@ -369,18 +375,25 @@ class Cri::CommandTestCase < Cri::TestCase
369
375
  c.be_hidden
370
376
  end
371
377
 
372
- refute cmd.help.include?('hidden commands ommitted')
373
- assert cmd.help.include?('hidden command ommitted')
378
+ refute cmd.help.include?('hidden commands omitted')
379
+ assert cmd.help.include?('hidden command omitted')
374
380
  refute cmd.help.include?('old-and-deprecated')
375
381
 
376
- refute cmd.help(:verbose => true).include?('hidden commands ommitted')
377
- refute cmd.help(:verbose => true).include?('hidden command ommitted')
382
+ refute cmd.help(:verbose => true).include?('hidden commands omitted')
383
+ refute cmd.help(:verbose => true).include?('hidden command omitted')
378
384
  assert cmd.help(:verbose => true).include?('old-and-deprecated')
379
385
  end
380
386
 
381
387
  def test_hidden_commands_multiple
382
388
  cmd = nested_cmd
383
389
 
390
+ subcmd = simple_cmd
391
+ cmd.add_command subcmd
392
+ subcmd.modify do |c|
393
+ c.name 'first'
394
+ c.summary 'does stuff first'
395
+ end
396
+
384
397
  subcmd = simple_cmd
385
398
  cmd.add_command subcmd
386
399
  subcmd.modify do |c|
@@ -397,15 +410,18 @@ class Cri::CommandTestCase < Cri::TestCase
397
410
  c.be_hidden
398
411
  end
399
412
 
400
- assert cmd.help.include?('hidden commands ommitted')
401
- refute cmd.help.include?('hidden command ommitted')
413
+ assert cmd.help.include?('hidden commands omitted')
414
+ refute cmd.help.include?('hidden command omitted')
402
415
  refute cmd.help.include?('old-and-deprecated')
403
416
  refute cmd.help.include?('ancient-and-deprecated')
404
417
 
405
- refute cmd.help(:verbose => true).include?('hidden commands ommitted')
406
- refute cmd.help(:verbose => true).include?('hidden command ommitted')
418
+ refute cmd.help(:verbose => true).include?('hidden commands omitted')
419
+ refute cmd.help(:verbose => true).include?('hidden command omitted')
407
420
  assert cmd.help(:verbose => true).include?('old-and-deprecated')
408
421
  assert cmd.help(:verbose => true).include?('ancient-and-deprecated')
422
+
423
+ pattern = /ancient-and-deprecated.*first.*old-and-deprecated/m
424
+ assert_match(pattern, cmd.help(:verbose => true))
409
425
  end
410
426
 
411
427
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cri
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-31 00:00:00.000000000 Z
11
+ date: 2013-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -72,12 +72,10 @@ email: denis.defreyne@stoneship.org
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files:
75
- - ChangeLog
76
75
  - LICENSE
77
76
  - README.md
78
77
  - NEWS.md
79
78
  files:
80
- - ChangeLog
81
79
  - Gemfile
82
80
  - Gemfile.lock
83
81
  - LICENSE
@@ -103,9 +101,9 @@ files:
103
101
  - test/test_core_ext.rb
104
102
  - test/test_option_parser.rb
105
103
  - cri.gemspec
106
- - .gemtest
107
104
  homepage: http://stoneship.org/software/cri/
108
- licenses: []
105
+ licenses:
106
+ - MIT
109
107
  metadata: {}
110
108
  post_install_message:
111
109
  rdoc_options:
@@ -125,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
123
  version: '0'
126
124
  requirements: []
127
125
  rubyforge_project:
128
- rubygems_version: 2.0.3
126
+ rubygems_version: 2.1.11
129
127
  signing_key:
130
128
  specification_version: 4
131
129
  summary: a library for building easy-to-use commandline tools
data/.gemtest DELETED
File without changes
data/ChangeLog DELETED
File without changes