home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume29 / parseargs / part01 / doc / cmd_macros.inc < prev    next >
Encoding:
Text File  |  1992-05-19  |  1.6 KB  |  58 lines

  1. .\"----------------------------------------------------------------------------
  2. .\"-- This text was extracted using the following command:
  3. .\"--   xdoc -man -p '[ \t]*' -s CMD-MACROS ../parseargs.h
  4. .\"----------------------------------------------------------------------------
  5. .SH "CMD MACROS"
  6. \f4<parseargs.h>\fP defines a set of macros to allow a more "self documenting"
  7. approach to declaring argument-descriptor arrays. The "old-style" is
  8. still accepted (but if used it is recommended that the \s-1STARTOFARGS\s+1
  9. macro is used in conjunction with \s-1ENDOFARGS\s+1).
  10. An example use of these macros (which, with one exception, all begin with
  11. ``\s-1CMD\s+1'') follows:
  12. .RS
  13. .nf
  14. .ft 4
  15. #include <parseargs.h>
  16.  
  17. static BOOL bflag = FALSE;
  18. static char *arg1 = CHARNULL;
  19. static char *arg2 = CHARNULL;
  20.  
  21. static
  22.    CMD_OBJECT
  23.       MyCmd
  24.  
  25.    CMD_NAME
  26.       "mycmd -- one line statement of purpose"
  27.  
  28.    CMD_DESCRIPTION
  29.       "Mycmd will try really really hard to run without errors \\
  30. and do whatever the heck it is supposed to do. If (God forbid) \\
  31. something should actually go wrong it will say so."
  32.  
  33.    CMD_ARGUMENTS
  34.       'H', ARGOPT, argUsage, __ NULL,
  35.       "Help -- display usage and quit",
  36.  
  37.       'b', ARGOPT, argSBool, __ &bflag,
  38.       "bflag -- turn on `b'-mode (whatever that is)",
  39.  
  40.       ' ', ARGREQ, argStr, __ &arg1,
  41.       "arg1 -- first argument to this spiffy program",
  42.  
  43.       ' ', ARGOPT, argStr, __ &arg2,
  44.       "arg2 -- optional second argument to this spiffy program",
  45.  
  46.       END_ARGUMENTS
  47.    CMD_END
  48.  
  49. main( int argc, char *argv[] )
  50. {
  51.    (void) parseargs( argv, MyCmd );
  52.    (void) dostuff();
  53.    exit( 0 );
  54. }
  55. .ft R
  56. .fi
  57. .RE
  58.