visionmedia-commander 3.2.3 → 3.2.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.
data/History.rdoc CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ === 3.2.4 / 2009-04-02
3
+
4
+ * Added #enable_paging [#9]
5
+
2
6
  === 3.2.3 / 2009-04-01
3
7
 
4
8
  * Added new pager using less [#9]
data/README.rdoc CHANGED
@@ -12,15 +12,16 @@ features, and an elegant API.
12
12
  * Parses options using OptionParser
13
13
  * Auto-populates struct with options ( no more { |v| options[:recursive] = v } )
14
14
  * Auto-generates help documentation via pluggable help formatters
15
+ * Optional default sub-command when none is present
16
+ * Global / Sub-command level options
15
17
  * Packaged with two help formatters (Terminal, TerminalCompact)
16
18
  * Imports the highline gem for interacting with the terminal
17
19
  * Adds additional user interaction functionality
18
20
  * Highly customizable progress bar with intuative, simple usage
19
21
  * Multi-word command name support such as 'drupal module install MOD', rather than 'drupal module_install MOD'
20
- * Use the 'commander' executable to initialize a commander driven program
21
- * Optional default sub-command when none is present
22
- * Global / Sub-command level options
22
+ * Sexy paging for long bodies of text
23
23
  * Sub-command aliasing (very powerful, as both switches and arguments can be used)
24
+ * Use the 'commander' executable to initialize a commander driven program
24
25
 
25
26
  == Example
26
27
 
@@ -143,6 +144,9 @@ simplify common tasks using the following methods:
143
144
  # 'Log' action to stdout
144
145
  log "create", "path/to/file.rb"
145
146
 
147
+ # Enable paging of output after this point
148
+ enable_paging
149
+
146
150
  == Commander Goodies
147
151
 
148
152
  === Option Defaults
data/commander.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{commander}
5
- s.version = "3.2.3"
5
+ s.version = "3.2.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
9
- s.date = %q{2009-04-01}
9
+ s.date = %q{2009-04-02}
10
10
  s.default_executable = %q{commander}
11
11
  s.description = %q{The complete solution for Ruby command-line executables}
12
12
  s.email = %q{tj@vision-media.ca}
@@ -251,6 +251,7 @@ module Commander
251
251
  c.example 'Display global help', 'command help'
252
252
  c.example "Display help for 'foo'", 'command help foo'
253
253
  c.when_called do |args, options|
254
+ enable_paging
254
255
  if args.empty?
255
256
  say help_formatter.render
256
257
  else
@@ -35,6 +35,28 @@ module Commander
35
35
  say '%15s %s' % [action, args.join(' ')]
36
36
  end
37
37
 
38
+ ##
39
+ # Enable paging of output after called.
40
+
41
+ def enable_paging
42
+ return unless $stdout.tty?
43
+ read, write = IO.pipe
44
+
45
+ if Kernel.fork
46
+ $stdin.reopen read
47
+ read.close; write.close
48
+ Kernel.select [$stdin]
49
+ ENV['LESS'] = 'FSRX'
50
+ pager = ENV['PAGER'] || 'less'
51
+ exec pager rescue exec '/bin/sh', '-c', pager
52
+ else
53
+ $stdout.reopen write
54
+ $stderr.reopen write if $stderr.tty?
55
+ read.close; write.close
56
+ return
57
+ end
58
+ end
59
+
38
60
  ##
39
61
  # = Progress Bar
40
62
  #
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Commander
3
- VERSION = '3.2.3'
3
+ VERSION = '3.2.4'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-01 00:00:00 -07:00
12
+ date: 2009-04-02 00:00:00 -07:00
13
13
  default_executable: commander
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency