gli 2.5.3 → 2.5.4

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.
@@ -30,14 +30,25 @@ module GLI
30
30
  }
31
31
  # The help command used for the two-level interactive help system
32
32
  class Help < Command
33
+ @@skips_pre = true
34
+ @@skips_post = true
35
+ @@skips_around = true
36
+
37
+ # Configure help to explicitly skip or not skip the pre block when the help command runs.
38
+ # This is here because the creation of the help command is outside of the client programmer's control
39
+ def self.skips_pre=(skips_pre) ; @@skips_pre = skips_pre ; end
40
+ # Configure help to explicitly skip or not skip the post block when the help command runs.
41
+ # This is here because the creation of the help command is outside of the client programmer's control
42
+ def self.skips_post=(skips_post) ; @@skips_post = skips_post ; end
43
+ # Configure help to explicitly skip or not skip the around block when the help command runs.
44
+ # This is here because the creation of the help command is outside of the client programmer's control
45
+ def self.skips_around=(skips_around) ; @@skips_around = skips_around ; end
46
+
33
47
  def initialize(app,output=$stdout,error=$stderr)
34
48
  super(:names => :help,
35
49
  :description => 'Shows a list of commands or help for one command',
36
50
  :arguments_name => 'command',
37
- :long_desc => 'Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function',
38
- :skips_pre => true,
39
- :skips_post => true,
40
- :skips_around => true)
51
+ :long_desc => 'Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function')
41
52
  @app = app
42
53
  @sorter = SORTERS[@app.help_sort_type]
43
54
  @text_wrapping_class = WRAPPERS[@app.help_text_wrap_type]
@@ -50,6 +61,10 @@ module GLI
50
61
  end
51
62
  end
52
63
 
64
+ def skips_pre ; @@skips_pre ; end
65
+ def skips_post ; @@skips_post ; end
66
+ def skips_around ; @@skips_around ; end
67
+
53
68
  private
54
69
 
55
70
  def show_help(global_options,options,arguments,out,error)
@@ -1,5 +1,5 @@
1
1
  module GLI
2
2
  unless const_defined? :VERSION
3
- VERSION = '2.5.3' #:nodoc:
3
+ VERSION = '2.5.4' #:nodoc:
4
4
  end
5
5
  end
@@ -10,6 +10,10 @@ class TC_testHelp < Clean::Test::TestCase
10
10
  @output = StringIO.new
11
11
  @error = StringIO.new
12
12
  @command_names_used = []
13
+ # Reset help command to its default state
14
+ GLI::Commands::Help.skips_pre = true
15
+ GLI::Commands::Help.skips_post = true
16
+ GLI::Commands::Help.skips_around = true
13
17
  end
14
18
 
15
19
  def teardown
@@ -32,6 +36,35 @@ class TC_testHelp < Clean::Test::TestCase
32
36
  assert_not_nil @command.long_description
33
37
  assert @command.skips_pre
34
38
  assert @command.skips_post
39
+ assert @command.skips_around
40
+ }
41
+ end
42
+
43
+ test_that "the help command can be configured to skip things declaratively" do
44
+ Given {
45
+ @command = GLI::Commands::Help.new(TestApp.new,@output,@error)
46
+ GLI::Commands::Help.skips_pre = false
47
+ GLI::Commands::Help.skips_post = false
48
+ GLI::Commands::Help.skips_around = false
49
+ }
50
+ Then {
51
+ assert !@command.skips_pre
52
+ assert !@command.skips_post
53
+ assert !@command.skips_around
54
+ }
55
+ end
56
+
57
+ test_that "the help command can be configured to skip things declaratively regardless of when it the object was created" do
58
+ Given {
59
+ GLI::Commands::Help.skips_pre = false
60
+ GLI::Commands::Help.skips_post = false
61
+ GLI::Commands::Help.skips_around = false
62
+ @command = GLI::Commands::Help.new(TestApp.new,@output,@error)
63
+ }
64
+ Then {
65
+ assert !@command.skips_pre
66
+ assert !@command.skips_post
67
+ assert !@command.skips_around
35
68
  }
36
69
  end
37
70
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-26 00:00:00.000000000 Z
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -333,7 +333,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  segments:
335
335
  - 0
336
- hash: -3516893403879120401
336
+ hash: -1157408326756213175
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  none: false
339
339
  requirements:
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  version: '0'
343
343
  segments:
344
344
  - 0
345
- hash: -3516893403879120401
345
+ hash: -1157408326756213175
346
346
  requirements: []
347
347
  rubyforge_project: gli
348
348
  rubygems_version: 1.8.23