gem-man 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,10 +3,11 @@ gem-man(1) -- view a gem's man page
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `gem man` <GEM>
7
- `gem man` --latest <GEM>
8
- `gem man` --exact <GEM>
9
- `gem man` --all
6
+ gem man <GEM>
7
+ gem man <SECTION> <GEM>
8
+ gem man --latest <GEM>
9
+ gem man --exact <GEM>
10
+ gem man --all
10
11
 
11
12
  ## DESCRIPTION
12
13
 
@@ -27,6 +28,14 @@ displayed.
27
28
  Man pages are any files whose extension is a single digit [0-9],
28
29
  e.g. `ron.1`.
29
30
 
31
+ ## SECTION
32
+
33
+ Specifying a `SECTION` as the first argument narrows the search to man
34
+ pages matching the provided section. For example, if the "mustache"
35
+ gem includes `man/mustache.1` and `man/mustache.5` the command `gem
36
+ man 1 mustache` will display `man/mustache.1` without asking if you'd
37
+ like to see `man/mustache.5`.
38
+
30
39
  ## OPTIONS
31
40
 
32
41
  `gem man`'s default mode of operation is to open a man page for a
@@ -54,6 +63,12 @@ See `gem help man` to view the options at any time.
54
63
 
55
64
  gem install gem-man
56
65
 
66
+ ## EXAMPLES
67
+
68
+ gem man mustache
69
+ gem man 1 ron
70
+ gem man -a
71
+
57
72
  ## BUGS
58
73
 
59
74
  Requires the `man(1)` script to be in your path, executable, and to
@@ -25,6 +25,10 @@ class Gem::Commands::ManCommand < Gem::Command
25
25
  end
26
26
  end
27
27
 
28
+ def usage
29
+ "gem man [SECTION] GEMNAME"
30
+ end
31
+
28
32
  def add_latest_version_option
29
33
  add_option('-l', '--latest',
30
34
  'If there are multiple versions, open the latest') do |value, options|
@@ -39,28 +43,39 @@ class Gem::Commands::ManCommand < Gem::Command
39
43
  end
40
44
 
41
45
  def arguments
46
+ "SECTION section of the manual to search\n" +
42
47
  "GEMNAME gem whose manual you wish to read"
43
48
  end
44
49
 
45
50
  def execute
51
+ if get_one_optional_argument =~ /^\d$/
52
+ section = get_one_optional_argument
53
+ end
54
+
46
55
  if options[:all]
47
56
  puts "These gems have man pages:", ''
48
57
  Gem.source_index.gems.each do |name, spec|
49
58
  puts "#{spec.name} #{spec.version}" if spec.has_manpage?
50
59
  end
51
60
  else
52
- # Grab our target gem.
53
- name = get_one_gem_name
61
+ # gem man 1 mustache
62
+ section, name, _ = options[:args]
63
+
64
+ if name.nil?
65
+ # gem man mustache
66
+ name, section = section, nil
67
+ end
54
68
 
55
69
  # Try to read manpages.
56
- read_manpage get_spec(name) { |s| s.has_manpage? }
70
+ read_manpage(get_spec(name), section)
57
71
  end
58
72
  end
59
73
 
60
- def read_manpage(spec)
74
+ def read_manpage(spec, section = nil)
61
75
  return if spec.nil?
62
76
 
63
- paths = spec.manpages
77
+ paths = spec.manpages(section)
78
+ return if paths.empty?
64
79
 
65
80
  # man/ron.1 => ron(1)
66
81
  names = paths.map do |path|
@@ -1,13 +1,13 @@
1
1
  class Gem::Specification
2
2
  # Does this specification include a manpage?
3
- def has_manpage?
4
- manpages.any?
3
+ def has_manpage?(section = nil)
4
+ manpages(section).any?
5
5
  end
6
6
 
7
7
  # Paths to the manpages included in this gem.
8
- def manpages
8
+ def manpages(section = nil)
9
9
  @files.select do |file|
10
- file =~ /man\/(.+).\d$/
10
+ file =~ /man\/(.+).#{section || '\d'}$/
11
11
  end
12
12
  end
13
13
  end
@@ -7,18 +7,16 @@
7
7
  \fBgem-man\fR \-\- view a gem's man page
8
8
  .
9
9
  .SH "SYNOPSIS"
10
- \fBgem man\fR \fIGEM\fR
11
10
  .
12
- .br
13
- \fBgem man\fR \-\-latest \fIGEM\fR
14
- .
15
- .br
16
- \fBgem man\fR \-\-exact \fIGEM\fR
17
- .
18
- .br
19
- \fBgem man\fR \-\-list
11
+ .nf
12
+
13
+ \fBgem man <GEM>
14
+ gem man <SECTION> <GEM>
15
+ gem man --latest <GEM>
16
+ gem man --exact <GEM>
17
+ gem man --all \fR
20
18
  .
21
- .br
19
+ .fi
22
20
  .
23
21
  .SH "DESCRIPTION"
24
22
  The \fBgem man\fR command can be used to display a man page for an
@@ -38,6 +36,13 @@ displayed.
38
36
  Man pages are any files whose extension is a single digit [0\-9],
39
37
  e.g. \fBron.1\fR.
40
38
  .
39
+ .SH "SECTION"
40
+ Specifying a \fBSECTION\fR as the first argument narrows the search to man
41
+ pages matching the provided section. For example, if the "mustache"
42
+ gem includes \fBman/mustache.1\fR and \fBman/mustache.5\fR the command \fBgem
43
+ man 1 mustache\fR will display \fBman/mustache.1\fR without asking if you'd
44
+ like to see \fBman/mustache.5\fR.
45
+ .
41
46
  .SH "OPTIONS"
42
47
  \fBgem man\fR's default mode of operation is to open a man page for a
43
48
  single gem or, if multiple man pages are found, ask which you'd like
@@ -74,6 +79,16 @@ See \fBgem help man\fR to view the options at any time.
74
79
  .
75
80
  .fi
76
81
  .
82
+ .SH "EXAMPLES"
83
+ .
84
+ .nf
85
+
86
+ \fBgem man mustache
87
+ gem man 1 ron
88
+ gem man -a \fR
89
+ .
90
+ .fi
91
+ .
77
92
  .SH "BUGS"
78
93
  Requires the \fBman(1)\fR script to be in your path, executable, and to
79
94
  accept a full path to a manual.
@@ -66,11 +66,12 @@
66
66
  <p><code>gem-man</code> -- view a gem's man page</p>
67
67
  <h2>SYNOPSIS</h2>
68
68
 
69
- <p><code>gem man</code> <var>GEM</var><br>
70
- <code>gem man</code> --latest <var>GEM</var><br>
71
- <code>gem man</code> --exact <var>GEM</var><br>
72
- <code>gem man</code> --list<br>
73
- </p>
69
+ <pre><code>gem man &lt;GEM&gt;
70
+ gem man &lt;SECTION&gt; &lt;GEM&gt;
71
+ gem man --latest &lt;GEM&gt;
72
+ gem man --exact &lt;GEM&gt;
73
+ gem man --all
74
+ </code></pre>
74
75
 
75
76
  <h2>DESCRIPTION</h2>
76
77
 
@@ -91,6 +92,14 @@ displayed.</p>
91
92
  <p>Man pages are any files whose extension is a single digit [0-9],
92
93
  e.g. <code>ron.1</code>.</p>
93
94
 
95
+ <h2>SECTION</h2>
96
+
97
+ <p>Specifying a <code>SECTION</code> as the first argument narrows the search to man
98
+ pages matching the provided section. For example, if the "mustache"
99
+ gem includes <code>man/mustache.1</code> and <code>man/mustache.5</code> the command <code>gem
100
+ man 1 mustache</code> will display <code>man/mustache.1</code> without asking if you'd
101
+ like to see <code>man/mustache.5</code>.</p>
102
+
94
103
  <h2>OPTIONS</h2>
95
104
 
96
105
  <p><code>gem man</code>'s default mode of operation is to open a man page for a
@@ -127,6 +136,13 @@ man</code> will ask which you'd prefer.</p>
127
136
  <pre><code>gem install gem-man
128
137
  </code></pre>
129
138
 
139
+ <h2>EXAMPLES</h2>
140
+
141
+ <pre><code>gem man mustache
142
+ gem man 1 ron
143
+ gem man -a
144
+ </code></pre>
145
+
130
146
  <h2>BUGS</h2>
131
147
 
132
148
  <p>Requires the <code>man(1)</code> script to be in your path, executable, and to
@@ -3,10 +3,11 @@ gem-man(1) -- view a gem's man page
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `gem man` <GEM>
7
- `gem man` --latest <GEM>
8
- `gem man` --exact <GEM>
9
- `gem man` --all
6
+ gem man <GEM>
7
+ gem man <SECTION> <GEM>
8
+ gem man --latest <GEM>
9
+ gem man --exact <GEM>
10
+ gem man --all
10
11
 
11
12
  ## DESCRIPTION
12
13
 
@@ -27,6 +28,14 @@ displayed.
27
28
  Man pages are any files whose extension is a single digit [0-9],
28
29
  e.g. `ron.1`.
29
30
 
31
+ ## SECTION
32
+
33
+ Specifying a `SECTION` as the first argument narrows the search to man
34
+ pages matching the provided section. For example, if the "mustache"
35
+ gem includes `man/mustache.1` and `man/mustache.5` the command `gem
36
+ man 1 mustache` will display `man/mustache.1` without asking if you'd
37
+ like to see `man/mustache.5`.
38
+
30
39
  ## OPTIONS
31
40
 
32
41
  `gem man`'s default mode of operation is to open a man page for a
@@ -54,6 +63,12 @@ See `gem help man` to view the options at any time.
54
63
 
55
64
  gem install gem-man
56
65
 
66
+ ## EXAMPLES
67
+
68
+ gem man mustache
69
+ gem man 1 ron
70
+ gem man -a
71
+
57
72
  ## BUGS
58
73
 
59
74
  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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath