~theorytoe/mman

f2204594508520b0573c1ffabfd061ac5bc46253 — theorytoe 1 year, 6 months ago 578ce7f
add: page query
3 files changed, 76 insertions(+), 19 deletions(-)

M README.md
M mman
M mman.1
M README.md => README.md +10 -3
@@ 10,17 10,24 @@ It allows for a variety of formats for authoring:

## installation

This script requires:
- scdoc
- sed
- grep
- findutils
- posix compilant /bin/sh (both dash & bash have worked well in my tests)

To install:
```
sudo make install
```
There are also a couple of patches:

There are also a couple of patches:
- `./no-scdoc.patch`  -- remove scdoc support
- `./no-troff.patch`  -- remove troff "support"
- `./nroff-fmt.patch` -- use nroff for manpages instead of man

patches can be applied/removed withe the following commands

Patches can be applied/removed withe the following commands:
```bash
# see patch(1) for more information
patch < [patch-name].patch    # apply patch

M mman => mman +23 -6
@@ 1,4 1,4 @@
#!/bin/sh
#!/bin/bash

# mman 0.0-a
# script for editing custom manual pages


@@ 50,6 50,7 @@ editman() {

# TODO: add support for adding templates
edittroff() {
	# search for name in all sections
	for i in $SECTION; do
		file="${MMANDIR}/$1.$i.man"
		if [ -f "$file" ]; then


@@ 57,6 58,9 @@ edittroff() {
			return $?
		fi
	done
	# if we cant find a page, edit with the first
	# possible section (0) if unset. If the section
	# has been set via option, it defaults to that
	for i in $SECTION; do
		"$EDITOR" "${MMANDIR}/$1.$i.man"
		return $?


@@ 64,6 68,7 @@ edittroff() {
}

editscdoc() {
	# search for name in all sections
	for i in $SECTION; do
		file=${SRCDIR}/$1.$i.scd
		if [ -f "$file" ]; then


@@ 72,6 77,9 @@ editscdoc() {
			return $?
		fi
	done
	# if we cant find a page, edit with the first
	# possible section (0) if unset. If the section
	# has been set via option, it defaults to that
	for i in $SECTION; do
		"$EDITOR" "${SRCDIR}/$1.$i.scd"
		compilepage "$1" # compile manpages after edit


@@ 119,6 127,14 @@ viewman() {
	done
}

listpages() {
	find ~/.mman/ -type f \( -name "*.man" -o -name "*.scd" \) \
		-exec sh -c "basename {} | rev | cut -d '.' -f3,2 | rev" ';' |\
		sed 's/\(.*\)\.\([0-9]\)/\1(\2)/' |\
		sort |\
		uniq
}

usage() {
	cat << EOF
usage: $(basename $0) [-e|-t|-s|-c|-l] [section] name


@@ 126,6 142,7 @@ usage: $(basename $0) [-e|-t|-s|-c|-l] [section] name
    -t Edit a troff -man manpage
    -s Edit an scdoc manpage
    -c Compile scdoc manpages
	-k Search through pages
    -l List available pages
What mmanual do you want?
EOF


@@ 149,11 166,11 @@ while [ $# -gt 0 ]; do
			compileman
			exit $?;;
		-l)
			find ~/.mman/ -type f \
				-exec sh -c "basename {} | rev | cut -d '.' -f3,2 | rev" ';' |\
				sed 's/\(.*\)\.\([0-9]\)/\1(\2)/' |\
				sort |\
				uniq
			listpages
			exit $?;;
		-k)
			shift
			listpages | grep "$1"
			exit $?;;
		-h|--help)
			usage

M mman.1 => mman.1 +43 -10
@@ 5,7 5,12 @@ mman \- write personal mmanpages

.SH SYNPOSYS
.B mman
.RI [ \-e | \-t | \-s | \-c | \-l ]
.RB [ \-l | \-c ]
.RB [ \-k
.IR query ]
.PP
.B mman
.RB [ \-e | \-t | \-s ]
.RI [ section ]
.I name



@@ 17,23 22,51 @@ requirement to conform to those standards. If a
Is not specified, new pages will default to secion 0, a non-standard section.

.TP
\fB \-e \fR
Edit a txt man page.
.B \-e 
.RI [ section ]
.I name
.IP
Edit a txt man page of name
.I name
and optionally
.IR section .
(section \fI0\fR by default).

.TP
\fB \-t \fR
Edit a troff man page.
.B \-t
.RI [ section ]
.I name
.IP
Edit a troff man page of name
.I name
and optionally
.IR section .
(section \fI0\fR by default).

.TP
\fB \-s \fR
Edit an scdoc man page. Compiles pages after edit.
.B \-s
.RI [ section ]
.I name
.IP
Edit an scdoc man page of name
.I name
and optionally
.IR section .
(section \fI0\fR by default).
.nf
Compiles pages after edit.
.fi

.TP
\fB \-c \fR
.B \-c
Compile scdoc manpages.

.TP
\fB \-l \fR
.B \-k
Search for \fIquery\fR in list of known mman pages.

.TP
.B \-l
List available pages.

.SH NOTES


@@ 62,4 95,4 @@ This is free software: you are free to change and redistribute it. There is NO W
the extent permitted by law.

.SH SEE ALSO
\fBman\fR(7) \fBman-pages\fR(7) \fBnroff\fR(1) \fBtroff\fR(1) \fBscdoc\fR(5) \fBless\fR(1)
\fBman\fR(7) \fBman-pages\fR(7) \fBnroff\fR(1) \fBtroff\fR(1) \fBgroff_man\fR(7) \fBscdoc\fR(5) \fBless\fR(1)