gem-man 0.1.3 → 0.2.0

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/README.md CHANGED
@@ -5,6 +5,7 @@ gem-man(1) -- view a gem's man page
5
5
 
6
6
  gem man <GEM>
7
7
  gem man <SECTION> <GEM>
8
+ gem man --system <GEM>
8
9
  gem man --latest <GEM>
9
10
  gem man --exact <GEM>
10
11
  gem man --all
@@ -52,6 +53,12 @@ man` will ask which you'd prefer.
52
53
 
53
54
  You can specify gems or list available gems using a few options.
54
55
 
56
+ * `-s`, `--system`:
57
+ Fall back to searching for system manuals. That is, `gem man -s
58
+ mac` will first look for a gem named `mac` with a man page before
59
+ looking for any system man pages named `mac`. `gem man -s fork`
60
+ should find the fork(2) manual, for instance.
61
+
55
62
  * `-l`, `--latest`:
56
63
  If there are multiple versions of a gem, open the latest.
57
64
 
@@ -83,6 +90,19 @@ For information on authoring man pages, see [`ron(7)`][r7]:
83
90
  gem install ron
84
91
  gem man 7 ron
85
92
 
93
+ ## CHEATING
94
+
95
+ If you want `man` to find RubyGems, it's this easy:
96
+
97
+ alias man="gem man -s"
98
+
99
+ Now:
100
+
101
+ man say
102
+ man rails
103
+ man 1 ronn
104
+ man 2 fork
105
+
86
106
  ## BUGS
87
107
 
88
108
  Requires the `man(1)` script to be in your path, executable, and to
@@ -13,11 +13,21 @@ class Gem::Commands::ManCommand < Gem::Command
13
13
  :all => false
14
14
 
15
15
  add_all_gems_option
16
+ add_system_fallback_option
16
17
  add_latest_version_option
17
18
  add_version_option
18
19
  add_exact_match_option
19
20
  end
20
21
 
22
+ def usage
23
+ "gem man [SECTION] GEMNAME"
24
+ end
25
+
26
+ def arguments
27
+ "SECTION section of the manual to search\n" +
28
+ "GEMNAME gem whose manual you wish to read"
29
+ end
30
+
21
31
  def add_all_gems_option
22
32
  add_option('-a', '--all',
23
33
  'List all installed gems that have manuals.') do |value, options|
@@ -25,8 +35,11 @@ class Gem::Commands::ManCommand < Gem::Command
25
35
  end
26
36
  end
27
37
 
28
- def usage
29
- "gem man [SECTION] GEMNAME"
38
+ def add_system_fallback_option
39
+ add_option('-s', '--system',
40
+ 'Falls back to searching for system-wide man pages.') do |value, options|
41
+ options[:system] = true
42
+ end
30
43
  end
31
44
 
32
45
  def add_latest_version_option
@@ -42,11 +55,6 @@ class Gem::Commands::ManCommand < Gem::Command
42
55
  end
43
56
  end
44
57
 
45
- def arguments
46
- "SECTION section of the manual to search\n" +
47
- "GEMNAME gem whose manual you wish to read"
48
- end
49
-
50
58
  def execute
51
59
  if get_one_optional_argument =~ /^\d$/
52
60
  section = get_one_optional_argument
@@ -67,8 +75,13 @@ class Gem::Commands::ManCommand < Gem::Command
67
75
  end
68
76
 
69
77
  # Try to read manpages.
70
- spec = get_spec(name) { |s| s.has_manpage?(section) }
71
- read_manpage(spec, section)
78
+ if spec = get_spec(name) { |s| s.has_manpage?(section) }
79
+ read_manpage(spec, section)
80
+ elsif options[:system]
81
+ exec "man #{section} #{name}"
82
+ else
83
+ abort "No manual entry for #{name}"
84
+ end
72
85
  end
73
86
  end
74
87
 
@@ -115,7 +128,6 @@ class Gem::Commands::ManCommand < Gem::Command
115
128
  pattern = /#{Regexp.escape name}/
116
129
  get_spec(pattern, &block)
117
130
  else
118
- say "Can't find any manpages for '#{name.inspect}"
119
131
  nil
120
132
  end
121
133
  elsif specs.length == 1 || options[:latest]
@@ -5,6 +5,7 @@ gem-man(1) -- view a gem's man page
5
5
 
6
6
  gem man <GEM>
7
7
  gem man <SECTION> <GEM>
8
+ gem man --system <GEM>
8
9
  gem man --latest <GEM>
9
10
  gem man --exact <GEM>
10
11
  gem man --all
@@ -52,6 +53,12 @@ man` will ask which you'd prefer.
52
53
 
53
54
  You can specify gems or list available gems using a few options.
54
55
 
56
+ * `-s`, `--system`:
57
+ Fall back to searching for system manuals. That is, `gem man -s
58
+ mac` will first look for a gem named `mac` with a man page before
59
+ looking for any system man pages named `mac`. `gem man -s fork`
60
+ should find the fork(2) manual, for instance.
61
+
55
62
  * `-l`, `--latest`:
56
63
  If there are multiple versions of a gem, open the latest.
57
64
 
@@ -83,6 +90,19 @@ For information on authoring man pages, see [`ron(7)`][r7]:
83
90
  gem install ron
84
91
  gem man 7 ron
85
92
 
93
+ ## CHEATING
94
+
95
+ If you want `man` to find RubyGems, it's this easy:
96
+
97
+ alias man="gem man -s"
98
+
99
+ Now:
100
+
101
+ man say
102
+ man rails
103
+ man 1 ronn
104
+ man 2 fork
105
+
86
106
  ## BUGS
87
107
 
88
108
  Requires the `man(1)` script to be in your path, executable, and to
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath