binman 4.2.1 → 5.0.1
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.
- checksums.yaml +4 -4
- data/README.markdown +122 -57
- data/VERSION.markdown +19 -0
- data/bin/binman +10 -4
- data/bin/binman-rake +1 -1
- data/binman.gemspec +1 -1
- data/lib/binman.rb +41 -28
- data/lib/binman/rakefile.rb +1 -1
- data/lib/binman/version.rb +1 -1
- data/man/index.html +1 -1
- data/man/man0/README.html +140 -75
- data/man/man0/VERSION.html +40 -27
- data/man/man1/binman-rake.1 +1 -1
- data/man/man1/binman-rake.1.html +4 -4
- data/man/man1/binman.1 +13 -3
- data/man/man1/binman.1.html +11 -8
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e363154d3d40c1918e0071dcfca3a2448c0ecb3f
|
|
4
|
+
data.tar.gz: 151ca6dec27d919b3e016bd1e024f79a7b9a5b80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db2a1c7af572165922a325a8865238f78ccf0472718d9cc33eab0bcb126739889cef7c8f7a7d1e05b11a57613fdf3e6783779d8a3d9a84261544833e435cfc11
|
|
7
|
+
data.tar.gz: e17e17541ce8a98d52f12b93604365d15cdc8572e5c18f87a256c72c4adb1672324b0af5d2092caa4e1d6a58506e2fb723fc9de4a744183c0ce1b1dba7ef318f
|
data/README.markdown
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Simply [document your script in Markdown][md2man-markdown] as a comment at the
|
|
5
5
|
top of your script and call `binman show` to display it as a UNIX manual page!
|
|
6
6
|
Or, call `binman help` to display your manual _only_ when your script receives
|
|
7
|
-
with `-h` or `--help` command-line options. Or, call `binman
|
|
7
|
+
with `-h` or `--help` command-line options. Or, call `binman text` to extract
|
|
8
8
|
the manual from your script for your own custom processing, outside of binman.
|
|
9
9
|
And that's not all: [see the manual page][binman-man] for more possibilities!
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ And that's not all: [see the manual page][binman-man] for more possibilities!
|
|
|
23
23
|
|
|
24
24
|
* Individual extraction, conversion, and display commands.
|
|
25
25
|
|
|
26
|
-
* Implemented in roughly
|
|
26
|
+
* Implemented in roughly 165 lines of pure Ruby code! :-)
|
|
27
27
|
|
|
28
28
|
### Demonstration
|
|
29
29
|
|
|
@@ -33,58 +33,123 @@ And that's not all: [see the manual page][binman-man] for more possibilities!
|
|
|
33
33
|
|
|
34
34
|
Here are some real examples of processed bin scripts to help you get started:
|
|
35
35
|
|
|
36
|
-
*
|
|
37
|
-
[tork
|
|
38
|
-
[tork.1](https://
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
[tork
|
|
42
|
-
|
|
43
|
-
[tork
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[tork-
|
|
47
|
-
[tork-
|
|
48
|
-
*
|
|
49
|
-
[tork-
|
|
50
|
-
[tork-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
[tork-
|
|
54
|
-
|
|
55
|
-
[tork-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[tork-
|
|
59
|
-
[tork-
|
|
60
|
-
*
|
|
61
|
-
[tork-
|
|
62
|
-
[tork-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[tork-
|
|
66
|
-
|
|
67
|
-
[tork-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
*
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
[
|
|
78
|
-
|
|
79
|
-
[
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
*
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
|
|
36
|
+
* `binman text`
|
|
37
|
+
< [tork](https://raw.github.com/sunaku/tork/master/bin/tork)
|
|
38
|
+
> [tork.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork.1.markdown)
|
|
39
|
+
* `binman roff`
|
|
40
|
+
< [tork](https://raw.github.com/sunaku/tork/master/bin/tork)
|
|
41
|
+
> [tork.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork.1)
|
|
42
|
+
* `binman html`
|
|
43
|
+
< [tork](https://raw.github.com/sunaku/tork/master/bin/tork)
|
|
44
|
+
> [tork.1.html](https://sunaku.github.io/tork/man/man1/tork.1.html)
|
|
45
|
+
* `binman text`
|
|
46
|
+
< [tork-runner](https://raw.github.com/sunaku/tork/master/bin/tork-runner)
|
|
47
|
+
> [tork-runner.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-runner.1.markdown)
|
|
48
|
+
* `binman roff`
|
|
49
|
+
< [tork-runner](https://raw.github.com/sunaku/tork/master/bin/tork-runner)
|
|
50
|
+
> [tork-runner.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-runner.1)
|
|
51
|
+
* `binman html`
|
|
52
|
+
< [tork-runner](https://raw.github.com/sunaku/tork/master/bin/tork-runner)
|
|
53
|
+
> [tork-runner.1.html](https://sunaku.github.io/tork/man/man1/tork-runner.1.html)
|
|
54
|
+
* `binman text`
|
|
55
|
+
< [tork-herald](https://raw.github.com/sunaku/tork/master/bin/tork-herald)
|
|
56
|
+
> [tork-herald.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-herald.1.markdown)
|
|
57
|
+
* `binman roff`
|
|
58
|
+
< [tork-herald](https://raw.github.com/sunaku/tork/master/bin/tork-herald)
|
|
59
|
+
> [tork-herald.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-herald.1)
|
|
60
|
+
* `binman html`
|
|
61
|
+
< [tork-herald](https://raw.github.com/sunaku/tork/master/bin/tork-herald)
|
|
62
|
+
> [tork-herald.1.html](https://sunaku.github.io/tork/man/man1/tork-herald.1.html)
|
|
63
|
+
* `binman text`
|
|
64
|
+
< [tork-driver](https://raw.github.com/sunaku/tork/master/bin/tork-driver)
|
|
65
|
+
> [tork-driver.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-driver.1.markdown)
|
|
66
|
+
* `binman roff`
|
|
67
|
+
< [tork-driver](https://raw.github.com/sunaku/tork/master/bin/tork-driver)
|
|
68
|
+
> [tork-driver.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-driver.1)
|
|
69
|
+
* `binman html`
|
|
70
|
+
< [tork-driver](https://raw.github.com/sunaku/tork/master/bin/tork-driver)
|
|
71
|
+
> [tork-driver.1.html](https://sunaku.github.io/tork/man/man1/tork-driver.1.html)
|
|
72
|
+
* `binman text`
|
|
73
|
+
< [tork-engine](https://raw.github.com/sunaku/tork/master/bin/tork-engine)
|
|
74
|
+
> [tork-engine.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-engine.1.markdown)
|
|
75
|
+
* `binman roff`
|
|
76
|
+
< [tork-engine](https://raw.github.com/sunaku/tork/master/bin/tork-engine)
|
|
77
|
+
> [tork-engine.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-engine.1)
|
|
78
|
+
* `binman html`
|
|
79
|
+
< [tork-engine](https://raw.github.com/sunaku/tork/master/bin/tork-engine)
|
|
80
|
+
> [tork-engine.1.html](https://sunaku.github.io/tork/man/man1/tork-engine.1.html)
|
|
81
|
+
* `binman text`
|
|
82
|
+
< [tork-master](https://raw.github.com/sunaku/tork/master/bin/tork-master)
|
|
83
|
+
> [tork-master.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-master.1.markdown)
|
|
84
|
+
* `binman roff`
|
|
85
|
+
< [tork-master](https://raw.github.com/sunaku/tork/master/bin/tork-master)
|
|
86
|
+
> [tork-master.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-master.1)
|
|
87
|
+
* `binman html`
|
|
88
|
+
< [tork-master](https://raw.github.com/sunaku/tork/master/bin/tork-master)
|
|
89
|
+
> [tork-master.1.html](https://sunaku.github.io/tork/man/man1/tork-master.1.html)
|
|
90
|
+
* `binman text`
|
|
91
|
+
< [tork-remote](https://raw.github.com/sunaku/tork/master/bin/tork-remote)
|
|
92
|
+
> [tork-remote.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-remote.1.markdown)
|
|
93
|
+
* `binman roff`
|
|
94
|
+
< [tork-remote](https://raw.github.com/sunaku/tork/master/bin/tork-remote)
|
|
95
|
+
> [tork-remote.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-remote.1)
|
|
96
|
+
* `binman html`
|
|
97
|
+
< [tork-remote](https://raw.github.com/sunaku/tork/master/bin/tork-remote)
|
|
98
|
+
> [tork-remote.1.html](https://sunaku.github.io/tork/man/man1/tork-remote.1.html)
|
|
99
|
+
* `binman text`
|
|
100
|
+
< [tork-notify](https://raw.github.com/sunaku/tork/master/bin/tork-notify)
|
|
101
|
+
> [tork-notify.1.markdown](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-notify.1.markdown)
|
|
102
|
+
* `binman roff`
|
|
103
|
+
< [tork-notify](https://raw.github.com/sunaku/tork/master/bin/tork-notify)
|
|
104
|
+
> [tork-notify.1](https://raw.github.com/sunaku/tork/gh-pages/man/man1/tork-notify.1)
|
|
105
|
+
* `binman html`
|
|
106
|
+
< [tork-notify](https://raw.github.com/sunaku/tork/master/bin/tork-notify)
|
|
107
|
+
> [tork-notify.1.html](https://sunaku.github.io/tork/man/man1/tork-notify.1.html)
|
|
108
|
+
* `binman text`
|
|
109
|
+
< [md2man-roff](https://raw.github.com/sunaku/md2man/master/bin/md2man-roff)
|
|
110
|
+
> [md2man-roff.1.markdown](https://raw.github.com/sunaku/md2man/gh-pages/man/man1/md2man-roff.1.markdown)
|
|
111
|
+
* `binman roff`
|
|
112
|
+
< [md2man-roff](https://raw.github.com/sunaku/md2man/master/bin/md2man-roff)
|
|
113
|
+
> [md2man-roff.1](https://raw.github.com/sunaku/md2man/gh-pages/man/man1/md2man-roff.1)
|
|
114
|
+
* `binman html`
|
|
115
|
+
< [md2man-roff](https://raw.github.com/sunaku/md2man/master/bin/md2man-roff)
|
|
116
|
+
> [md2man-roff.1.html](https://sunaku.github.io/md2man/man/man1/md2man-roff.1.html)
|
|
117
|
+
* `binman text`
|
|
118
|
+
< [md2man-html](https://raw.github.com/sunaku/md2man/master/bin/md2man-html)
|
|
119
|
+
> [md2man-html.1.markdown](https://raw.github.com/sunaku/md2man/gh-pages/man/man1/md2man-html.1.markdown)
|
|
120
|
+
* `binman roff`
|
|
121
|
+
< [md2man-html](https://raw.github.com/sunaku/md2man/master/bin/md2man-html)
|
|
122
|
+
> [md2man-html.1](https://raw.github.com/sunaku/md2man/gh-pages/man/man1/md2man-html.1)
|
|
123
|
+
* `binman html`
|
|
124
|
+
< [md2man-html](https://raw.github.com/sunaku/md2man/master/bin/md2man-html)
|
|
125
|
+
> [md2man-html.1.html](https://sunaku.github.io/md2man/man/man1/md2man-html.1.html)
|
|
126
|
+
* `binman text`
|
|
127
|
+
< [md2man-rake](https://raw.github.com/sunaku/md2man/master/bin/md2man-rake)
|
|
128
|
+
> [md2man-rake.1.markdown](https://raw.github.com/sunaku/md2man/gh-pages/man/man1/md2man-rake.1.markdown)
|
|
129
|
+
* `binman roff`
|
|
130
|
+
< [md2man-rake](https://raw.github.com/sunaku/md2man/master/bin/md2man-rake)
|
|
131
|
+
> [md2man-rake.1](https://raw.github.com/sunaku/md2man/gh-pages/man/man1/md2man-rake.1)
|
|
132
|
+
* `binman html`
|
|
133
|
+
< [md2man-rake](https://raw.github.com/sunaku/md2man/master/bin/md2man-rake)
|
|
134
|
+
> [md2man-rake.1.html](https://sunaku.github.io/md2man/man/man1/md2man-rake.1.html)
|
|
135
|
+
* `binman text`
|
|
136
|
+
< [binman](https://raw.github.com/sunaku/binman/master/bin/binman)
|
|
137
|
+
> [binman.1.markdown](https://raw.github.com/sunaku/binman/gh-pages/man/man1/binman.1.markdown)
|
|
138
|
+
* `binman roff`
|
|
139
|
+
< [binman](https://raw.github.com/sunaku/binman/master/bin/binman)
|
|
140
|
+
> [binman.1](https://raw.github.com/sunaku/binman/gh-pages/man/man1/binman.1)
|
|
141
|
+
* `binman html`
|
|
142
|
+
< [binman](https://raw.github.com/sunaku/binman/master/bin/binman)
|
|
143
|
+
> [binman.1.html](https://sunaku.github.io/binman/man/man1/binman.1.html)
|
|
144
|
+
* `binman text`
|
|
145
|
+
< [binman-rake](https://raw.github.com/sunaku/binman/master/bin/binman-rake)
|
|
146
|
+
> [binman-rake.1.markdown](https://raw.github.com/sunaku/binman/gh-pages/man/man1/binman-rake.1.markdown)
|
|
147
|
+
* `binman roff`
|
|
148
|
+
< [binman-rake](https://raw.github.com/sunaku/binman/master/bin/binman-rake)
|
|
149
|
+
> [binman-rake.1](https://raw.github.com/sunaku/binman/gh-pages/man/man1/binman-rake.1)
|
|
150
|
+
* `binman html`
|
|
151
|
+
< [binman-rake](https://raw.github.com/sunaku/binman/master/bin/binman-rake)
|
|
152
|
+
> [binman-rake.1.html](https://sunaku.github.io/binman/man/man1/binman-rake.1.html)
|
|
88
153
|
|
|
89
154
|
For examples in even more scripting languages, see the "Usage" section below!
|
|
90
155
|
|
|
@@ -107,7 +172,7 @@ gem install binman
|
|
|
107
172
|
If you also want to build your own manual pages:
|
|
108
173
|
|
|
109
174
|
```sh
|
|
110
|
-
gem install md2man -v '~>
|
|
175
|
+
gem install md2man -v '~> 5.0'
|
|
111
176
|
```
|
|
112
177
|
|
|
113
178
|
### Prerequisites
|
|
@@ -117,7 +182,7 @@ gem install md2man -v '~> 4.0'
|
|
|
117
182
|
### Development
|
|
118
183
|
|
|
119
184
|
```sh
|
|
120
|
-
git clone
|
|
185
|
+
git clone https://github.com/sunaku/binman
|
|
121
186
|
cd binman
|
|
122
187
|
bundle install
|
|
123
188
|
bundle exec binman --help # run it directly
|
|
@@ -342,7 +407,7 @@ Add this snippet to your gemspec file:
|
|
|
342
407
|
```ruby
|
|
343
408
|
s.files += Dir['man/man?/*.?'] # UNIX man pages
|
|
344
409
|
s.files += Dir['man/**/*.{html,css,js}'] # HTML man pages
|
|
345
|
-
s.add_development_dependency 'md2man', '~>
|
|
410
|
+
s.add_development_dependency 'md2man', '~> 5.0'
|
|
346
411
|
```
|
|
347
412
|
|
|
348
413
|
Add the following line to your Rakefile:
|
data/VERSION.markdown
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## Version 5.0.1 (2016-02-13)
|
|
2
|
+
|
|
3
|
+
### Major:
|
|
4
|
+
|
|
5
|
+
* Rename `binman snip` command to `binman text`.
|
|
6
|
+
|
|
7
|
+
* Rename `binman conv` command to `binman roff` and make it operate on a bin
|
|
8
|
+
script containing an embedded manual page rather than the extracted latter.
|
|
9
|
+
|
|
10
|
+
* Add `binman html` command which extracts embedded manual page from a given
|
|
11
|
+
bin script, converts it into HTML, and then prints the result to STDOUT.
|
|
12
|
+
|
|
13
|
+
* `binman show` now falls back to displaying a temporary HTML manual page if
|
|
14
|
+
man(1) fails to display the temporary UNIX manual page. This is useful in
|
|
15
|
+
Windows where there is no man(1) reader, but a web browser can be started.
|
|
16
|
+
|
|
17
|
+
* When a HTML manual page is shown, `binman` now blocks until the launched
|
|
18
|
+
web browser exits. Previously, it used to exit immediately (nonblocking).
|
|
19
|
+
|
|
1
20
|
## Version 4.2.1 (2016-02-12)
|
|
2
21
|
|
|
3
22
|
### Patch:
|
data/bin/binman
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
=begin =======================================================================
|
|
3
3
|
|
|
4
|
-
# BINMAN 1 2016-02-
|
|
4
|
+
# BINMAN 1 2016-02-13 5.0.1
|
|
5
5
|
|
|
6
6
|
## NAME
|
|
7
7
|
|
|
@@ -64,17 +64,23 @@ The following [Redcarpet] extensions are enabled while processing markdown(7):
|
|
|
64
64
|
|
|
65
65
|
## COMMANDS
|
|
66
66
|
|
|
67
|
-
`
|
|
67
|
+
`text` [*FILE*]
|
|
68
68
|
Print the leading comment header extracted from the given *FILE* or STDIN.
|
|
69
69
|
|
|
70
|
-
`
|
|
70
|
+
`roff` [*FILE*]
|
|
71
71
|
Print the roff(7) conversion of the leading comment header extracted from
|
|
72
72
|
the given *FILE* or STDIN.
|
|
73
73
|
|
|
74
|
+
`html` [*FILE*]
|
|
75
|
+
Print the HTML conversion of the leading comment header extracted from
|
|
76
|
+
the given *FILE* or STDIN.
|
|
77
|
+
|
|
74
78
|
`show` [*FILE*] [*PATTERN*]
|
|
75
79
|
Use man(1) to display the roff(7) conversion of the leading comment header
|
|
76
80
|
extracted from the given *FILE* or STDIN. If *PATTERN* is given, search for
|
|
77
81
|
it within the output displayed by man(1) and jump to first match if found.
|
|
82
|
+
If man(1) cannot display the roff(1) conversion, fall back to the showing
|
|
83
|
+
the HTML conversion; if that fails too, display the extracted text as-is.
|
|
78
84
|
|
|
79
85
|
`help` *FILE* ... [`-h`|`--help` [*PATTERN*]] ... [`--`] ...
|
|
80
86
|
If the given argument sequence contains `-h` or `--help`, except after
|
|
@@ -107,7 +113,7 @@ else
|
|
|
107
113
|
case command
|
|
108
114
|
when 'show'
|
|
109
115
|
BinMan.send(command, source)
|
|
110
|
-
when '
|
|
116
|
+
when 'text', 'roff', 'html'
|
|
111
117
|
puts BinMan.send(command, source)
|
|
112
118
|
else
|
|
113
119
|
warn 'binman: invalid command; try --help'
|
data/bin/binman-rake
CHANGED
data/binman.gemspec
CHANGED
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
|
|
19
19
|
s.files += Dir['man/man?/*.?'] # UNIX man pages
|
|
20
20
|
s.files += Dir['man/**/*.{html,css,js}'] # HTML man pages
|
|
21
|
-
s.add_development_dependency 'md2man', '~>
|
|
21
|
+
s.add_development_dependency 'md2man', '~> 5.0'
|
|
22
22
|
|
|
23
23
|
s.add_dependency 'opener', '>= 0.1.0', '< 1'
|
|
24
24
|
s.add_development_dependency 'rake', '~> 10.1'
|
data/lib/binman.rb
CHANGED
|
@@ -16,7 +16,7 @@ module BinMan
|
|
|
16
16
|
#
|
|
17
17
|
# Comment markers and shebang/encoding comments are omitted from result.
|
|
18
18
|
#
|
|
19
|
-
def
|
|
19
|
+
def text source=nil
|
|
20
20
|
header = read(source)
|
|
21
21
|
|
|
22
22
|
# strip shebang and encoding comments
|
|
@@ -31,10 +31,14 @@ module BinMan
|
|
|
31
31
|
end.strip
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
# Renders leading comment header from given source as UNIX man page.
|
|
35
|
+
def roff source=nil
|
|
36
|
+
to_roff text(source)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Renders leading comment header from given source as HTML man page.
|
|
40
|
+
def html source=nil
|
|
41
|
+
to_html text(source)
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
# Shows leading comment header from given source as UNIX man page and
|
|
@@ -50,7 +54,7 @@ module BinMan
|
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
# fall back to rendering leading comment header or showing it as-is
|
|
53
|
-
header =
|
|
57
|
+
header = text(source)
|
|
54
58
|
return if show_str(header, query)
|
|
55
59
|
puts header
|
|
56
60
|
end
|
|
@@ -71,23 +75,6 @@ module BinMan
|
|
|
71
75
|
|
|
72
76
|
private
|
|
73
77
|
|
|
74
|
-
# Launches man(1) with the given arguments and then tries to search for the
|
|
75
|
-
# query (if given) within. This is achieved by specifying the LESS and MORE
|
|
76
|
-
# environment variables used by the less(1) and more(1) pagers respectively.
|
|
77
|
-
def view query, *argv
|
|
78
|
-
env = query ? {'LESS' => [ENV['LESS'], "+/#{query}"].compact.join(' '),
|
|
79
|
-
'MORE' => [ENV['MORE'], "+/#{query}"].compact.join(' ')} : {}
|
|
80
|
-
system env, 'man', *argv
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Converts given markdown(7) source into roff(7).
|
|
84
|
-
def conv source=nil
|
|
85
|
-
require 'md2man/roff/engine'
|
|
86
|
-
Md2Man::Roff::ENGINE.render(read(source))
|
|
87
|
-
rescue LoadError
|
|
88
|
-
raise 'Run `gem install md2man` to use BinMan::dump() or BinMan::show().'
|
|
89
|
-
end
|
|
90
|
-
|
|
91
78
|
# Returns contents of given source I/O, file name, or string.
|
|
92
79
|
def read source=nil
|
|
93
80
|
if source.respond_to? :read
|
|
@@ -112,16 +99,15 @@ private
|
|
|
112
99
|
def show_man path, page, query=nil
|
|
113
100
|
# try showing roff manual page in man(1) reader in foreground
|
|
114
101
|
Dir["#{path}/man?/#{page}.?"].any? and
|
|
115
|
-
|
|
102
|
+
launch_man query, '-M', path, '-a', page, 2 => :close or
|
|
116
103
|
begin
|
|
117
104
|
# try showing HTML manual page in a web browser in background
|
|
118
105
|
require 'opener'
|
|
119
106
|
Dir["#{path}/**/#{page}.*.html"].map do |html|
|
|
107
|
+
puts html
|
|
120
108
|
begin
|
|
121
109
|
# close streams to avoid interference with man(1) reader
|
|
122
|
-
Opener.
|
|
123
|
-
puts html
|
|
124
|
-
true
|
|
110
|
+
Opener.system html, 0 => :close, 1 => :close, 2 => :close
|
|
125
111
|
rescue Errno::ENOENT
|
|
126
112
|
# designated opener program was not found on this system
|
|
127
113
|
end
|
|
@@ -129,10 +115,20 @@ private
|
|
|
129
115
|
end
|
|
130
116
|
end
|
|
131
117
|
|
|
118
|
+
# Launches man(1) with the given arguments and then tries to search for the
|
|
119
|
+
# query (if given) within. This is achieved by specifying the LESS and MORE
|
|
120
|
+
# environment variables used by the less(1) and more(1) pagers respectively.
|
|
121
|
+
def launch_man query, *argv
|
|
122
|
+
env = query ? {'LESS' => [ENV['LESS'], "+/#{query}"].compact.join(' '),
|
|
123
|
+
'MORE' => [ENV['MORE'], "+/#{query}"].compact.join(' ')} : {}
|
|
124
|
+
system env, 'man', *argv
|
|
125
|
+
end
|
|
126
|
+
|
|
132
127
|
# Tries to display the given header string in man(1) reader
|
|
133
128
|
# and returns true if successful; else you need a fallback.
|
|
134
129
|
def show_str header, query=nil
|
|
135
|
-
roff =
|
|
130
|
+
roff = to_roff(header)
|
|
131
|
+
html = to_html(header)
|
|
136
132
|
|
|
137
133
|
require 'tempfile'
|
|
138
134
|
Tempfile.open 'binman' do |temp|
|
|
@@ -146,6 +142,7 @@ private
|
|
|
146
142
|
|
|
147
143
|
# write the given header string to temporary file and show it
|
|
148
144
|
File.open(temp_man_file, 'w') {|file| file << roff }
|
|
145
|
+
File.open(temp_man_file + '.html', 'w') {|file| file << html }
|
|
149
146
|
return true if show_man(temp_man_path, temp_man_page, query)
|
|
150
147
|
ensure
|
|
151
148
|
FileUtils.rm_rf temp_man_root
|
|
@@ -156,4 +153,20 @@ private
|
|
|
156
153
|
rescue => error
|
|
157
154
|
warn "binman: #{error}"
|
|
158
155
|
end
|
|
156
|
+
|
|
157
|
+
# Converts given markdown(7) source into roff(7).
|
|
158
|
+
def to_roff source=nil
|
|
159
|
+
require 'md2man/roff/engine'
|
|
160
|
+
Md2Man::Roff::ENGINE.render(read(source))
|
|
161
|
+
rescue LoadError
|
|
162
|
+
raise 'Run `gem install md2man` to use BinMan::roff().'
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Converts given markdown(7) source into roff(7).
|
|
166
|
+
def to_html source=nil
|
|
167
|
+
require 'md2man/html/engine'
|
|
168
|
+
Md2Man::HTML::ENGINE.render(read(source))
|
|
169
|
+
rescue LoadError
|
|
170
|
+
raise 'Run `gem install md2man` to use BinMan::html().'
|
|
171
|
+
end
|
|
159
172
|
end
|
data/lib/binman/rakefile.rb
CHANGED