From 30dcb98c58694ef9d5678fc230695a51910c8314 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Tue, 5 May 2009 13:12:23 +0000 Subject: 20090505-1411 --- appl/cmd/man2html.b | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'appl/cmd') diff --git a/appl/cmd/man2html.b b/appl/cmd/man2html.b index 21f83284..f32c4fbd 100644 --- a/appl/cmd/man2html.b +++ b/appl/cmd/man2html.b @@ -16,6 +16,8 @@ include "daytime.m"; include "string.m"; str: String; +include "arg.m"; + Man2html: module { init: fn(ctxt: ref Draw->Context, args: list of string); @@ -315,10 +317,12 @@ Global: adt { softp: fn(g: self ref Global): string; }; +header := ""; +trailer := ""; usage() { - sys->fprint(stderr, "Usage: man2html file [section]\n"); + sys->fprint(stderr, "Usage: man2html [-h header] [-t trailer] file [section]\n"); raise "fail:usage"; } @@ -329,11 +333,20 @@ init(nil: ref Draw->Context, args: list of string) stderr = sys->fildes(2); str = load String String->PATH; dt = load Daytime Daytime->PATH; - g := Global_init(); - if(args != nil) - args = tl args; + arg := load Arg Arg->PATH; + arg->init(args); + arg->setusage("man2html [-h header] [-t trailer] file [section]"); + while((o := arg->opt()) != 0) + case o { + 'h' => header = arg->earg(); + 't' => trailer = arg->earg(); + * => arg->usage(); + } + args = arg->argv(); if(args == nil) - usage(); + arg->usage(); + arg = nil; + g := Global_init(); page := hd args; args = tl args; section := "1"; @@ -341,6 +354,7 @@ init(nil: ref Draw->Context, args: list of string) section = hd args; hit := Hit ("", "man", section, page); domanpage(g, hit); + g.print(trailer+"\n"); g.bufio->g.bout.flush(); } @@ -1342,7 +1356,7 @@ title(g: ref Global, t: string, search: int) { if(search) ; # not yet used - g.print("\n"); + g.print(header+"\n"); g.print(sprint("Inferno's %s\n", demark(t))); g.print("\n"); g.print("\n"); -- cgit v1.2.3