From 96add4441605991d48fcdee861c115216d355f6f Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 30 Oct 2002 18:22:37 +0000 Subject: [PATCH] RJK's `pterm --help' patch. I _must_ find a better alternative to this init sequence - it surely can't be right that `pterm --help' with no DISPLAY complains at the lack of DISPLAY rather than giving a help message! git-svn-id: svn://svn.tartarus.org/sgt/putty@2164 cda61777-01e9-0310-a592-d414129be87e --- unix/pterm.1 | 2 ++ unix/pterm.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/unix/pterm.1 b/unix/pterm.1 index 16436158..8e55e946 100644 --- a/unix/pterm.1 +++ b/unix/pterm.1 @@ -103,6 +103,8 @@ resources which do not have their own command-line options. For example: pterm -xrm 'ScrollbarOnLeft: 1' +.IP "\fB-help\fP, \fB--help\fP" +Display a message summarizing the available options .SH X RESOURCES \fIpterm\fP can be more completely configured by means of X resources. All of these resources are of the form \fIpterm.FOO\fP diff --git a/unix/pterm.c b/unix/pterm.c index 4113e510..e53499d5 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -1728,6 +1728,33 @@ char *get_x_display(void *frontend) char *app_name = "pterm"; +static void help(FILE *fp) { + if(fprintf(fp, +"pterm option summary:\n" +"\n" +" --display DISPLAY Specify X display to use (note '--')\n" +" -name PREFIX Prefix when looking up resources (default: pterm)\n" +" -fn FONT Normal text font\n" +" -fb FONT Bold text font\n" +" -geometry WIDTHxHEIGHT Size of terminal in characters\n" +" -sl LINES Number of lines of scrollback\n" +" -fg COLOUR, -bg COLOUR Foreground/background colour\n" +" -bfg COLOUR, -bbg COLOUR Foreground/background bold colour\n" +" -cfg COLOUR, -bfg COLOUR Foreground/background cursor colour\n" +" -T TITLE Window title\n" +" -ut, +ut Do(default) or do not update utmp\n" +" -ls, +ls Do(default) or do not make shell a login shell\n" +" -sb, +sb Do(default) or do not display a scrollbar\n" +" -log PATH Log all output to a file\n" +" -nethack Map numeric keypad to hjklyubn direction keys\n" +" -xrm RESOURCE-STRING Set an X resource\n" +" -e COMMAND [ARGS...] Execute command (consumes all remaining args)\n" + ) < 0 || fflush(fp) < 0) { + perror("output error"); + exit(1); + } +} + int do_cmdline(int argc, char **argv, int do_everything) { int err = 0; @@ -1881,6 +1908,10 @@ int do_cmdline(int argc, char **argv, int do_everything) EXPECTS_ARG; provide_xrm_string(val); + } else if(!strcmp(p, "-help") || !strcmp(p, "--help")) { + help(stdout); + exit(0); + } else { err = 1; fprintf(stderr, "pterm: unrecognized option '%s'\n", p); -- 2.11.0