Next: , Previous: Basic Usage, Up: Top   [Contents][Index]


3 gengetopt¤Î¸Æ¤Ó½Ð¤·

°Ê²¼¤Ïgengetopt --help¤Î½ÐÎϤǤ¹¡¥

gengetopt 

This program generates a C function that uses getopt_long function
to parse the command line options, validate them and fill a struct.

Usage: gengetopt [OPTIONS]...

  -h, --help                  Print help and exit
  -V, --version               Print version and exit
  -i, --input=filename        input file (default std input)
  -f, --func-name=name        name of generated function  
                                (default=`cmdline_parser')
  -a, --arg-struct-name=name  name of generated args info struct  
                                (default=`gengetopt_args_info')
  -F, --file-name=name        name of generated file  (default=`cmdline')
  -c, --c-extension=ext       extension of c file  (default=`c')
  -H, --header-extension=ext  extension of header file  (default=`h')
  -l, --long-help             long usage line in help
  -u, --unamed-opts[=STRING]  accept options without names (e.g., file names)  
                                (default=`FILES')
  -n, --no-handle-help        do not handle --help|-h automatically
  -N, --no-handle-version     do not handle --version|-V automatically
  -e, --no-handle-error       do not exit on errors
  -g, --gen-version           put gengetopt version in the generated file  
                                (default=on)
  -C, --conf-parser           generate a config file parser
      --set-package=STRING    set the package name (override package defined in 
                                the .ggo file)
      --set-version=STRING    set the version number (override version defined 
                                in the .ggo file)
      --show-help             show the output of --help instead of generating 
                                code
      --show-version          show the output of --version instead of 
                                generating code

¥ª¥×¥·¥ç¥ó¤Ï¡¤ÆÃ¤Ë¡¤¤Ï¤Ã¤­¤ê¤È¤µ¤»¤Æ¤ª¤¯¤Ù¤­¤Ç¤·¤ç¤¦¡¥

--func-name

--func-name¤¬¤¢¤¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¤cmdline_parser¤¬¥Ç¥Õ¥© ¥ë¥È¤Ë¤Ê¤ê¤Þ¤¹¡¥

--arg-struct-name

¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤ËÂбþ¤·¤ÆÀ¸À®¤µ¤ì¤ë¹½Â¤ÂΤÎ̾Á°¤ò»ØÄꤹ¤ë¤³¤È¤¬²Äǽ ¤Ç¤¹(¥Ç¥Õ¥©¥ë¥È¤Ïgengetopt_args_info)¡¥

--long-help

“Usage”¹Ô¤Ç¡¤¤¹¤Ù¤Æ¤Î¥ª¥×¥·¥ç¥ó¤òɽ¼¨¤·¤Þ¤¹¡¥¤³¤ì¤Ï¡¤¥ª¥×¥·¥ç¥ó¤¬Â¿¤¤ ¾ì¹ç¡¤¤è¤í¤³¤Ð¤·¤¯¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡¥

--unamed-opts

¥×¥í¥°¥é¥à¤Ï¡¤Ì¾Á°¤Î̵¤¤¥ª¥×¥·¥ç¥ó¤â¼õ¤±Æþ¤ì¡¤¤½¤ì¤Ï¤Û¤È¤ó¤É¤Î¾õ¶·¤Ç¡¤ ¥×¥í¥°¥é¥à¤Ë¿¤¯¤Î¥Õ¥¡¥¤¥ë̾¤òÅϤ¹¤³¤È¤¬²Äǽ¤Ë¤Ê¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹ (sample1 *.h¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ëBasic Usage¤ÎÎã¤ò»²¾È¤·¤Æ²¼¤µ ¤¤)¡¥¤³¤ì¤é¤ÎÄɲäÎ̾Á°¤Ë¥ª¥×¥·¥ç¥ó¤Îµ­½Ò¤ò»ØÄꤹ¤ë¤³¤È¤¬²Äǽ¤Ç¤¹(¥Ç¥Õ¥© ¥ë¥È¤ÏFILES¤Ç¤¹)¡¥

--no-handle-help
--no-handle-version

--no-handle-help (--no-handle-version)¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤ë¾ì ¹ç¡¤¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó--help|-h (--version|-V)¤Ï¡¤ ¼«Æ°Åª¤Ë½èÍý¤µ¤ì¤Ê¤¤¤Î¤Ç¡¤¥×¥í¥°¥é¥Þ¤Ï¤½¤ì°Ê³°¤Î¥ª¥×¥·¥ç¥ó¤ò½ÐÎϤ¹¤ë¤³ ¤È¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡¥É¸½àŪ¤Ê¥Ø¥ë¥×(¥Ð¡¼¥¸¥ç¥ó)¤ËÂбþ¤·¤Æ½ÐÎϤ¹¤ë´Ø¿ô¤Ï »ÈÍѲÄǽ¤Ç¤¹¡¥¤³¤Î´Ø¿ô¤Ï¡¤<parser-name>_print_help (<parser-name>_print_version)¤È¸Æ¤Ð¤ì¡¤<parser-name>¤Î̾ Á°¤Ï¡¤--func-name¤Ç»ØÄꤵ¤ì¤¿¤â¤Î¡¤¤Þ¤¿¤Ï¥Ç¥Õ¥©¥ë¥È¤Î cmdline_parser¤Ë¤Ê¤ê¤Þ¤¹¡¥

--no-handle-error

--no-handle-error¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤ë¾ì¹ç¡¤¹½Ê¸²òÀÏ»þ¤Î¥¨¥é¡¼¤Ç¡¤¥× ¥í¥°¥é¥à¤Î½ªÎ»¥³¡¼¥É¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤»¤ó¡¥¤½¤ÎÂå¤ï¤ê¤Ë¡¤¹½Ê¸²òÀÏ´Ø¿ô¤Ï¡¤ ¥¨¥é¡¼»þ¤Ë¤Ï0°Ê³°¤ÎÃͤòÊÖ¤·¡¤¥×¥í¥°¥é¥à¤Ï¥Ø¥ë¥×¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ·¡¤ gengetopt¼«¿È¤¬¥¨¥é¡¼»þ¤Ë¹Ô¤¦¤³¤È¤ÈƱ¤¸¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹(»î¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡ª)¡¥

--gen-version

¤³¤ì¤Ï¥Õ¥é¥°(¥Ç¥Õ¥©¥ë¥È¤Çon)¤Ç¡¤ÍøÍÑÉÔ²Äǽ¤Ê¤È¤­¤Ï½ÐÎÏ¥Õ¥¡¥¤¥ë¤Ë gengetopt¤Î¥Ð¡¼¥¸¥ç¥ó¤ò½ñ¤­½Ð¤·¤Þ¤»¤ó(¥Æ¥¹¥ÈÌÜŪ¤ÇÌò¤ËΩ¤Á¤Þ¤¹)¡¥

´û¤Ë¤ªÊ¬¤«¤ê¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¡¤gengetopt¤Ïgengetopt¼«¿È¤ò¡¤¥³¥Þ¥ó¥É¥é¥¤ ¥ó¥ª¥×¥·¥ç¥ó¤ËÂФ·¤Æ»ÈÍѤ·¤Æ¤¤¤Æ¡¤¤½¤Î»ÅÍͤ¬½ñ¤«¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Ï¥½¡¼ ¥¹¥Ç¥£¥ì¥¯¥È¥ê¤Îcmdline.ggo¤Ç¤¹¡¥ÆÃ¤Ë¡¤gengetopt¼«¿È¤Î¥³¥Þ¥ó¥É¥é ¥¤¥ó¤Ï¡¤°Ê²¼¤Î¥³¥Þ¥ó¥É¤ÇÀ¸À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥

gengetopt --input=cmdline.ggo --no-handle-version \
          --no-handle-help --no-handle-error

¼ÂºÝ¡¤--help|-h¤¬¥³¥Þ¥ó¥É¥é¥¤¥ó¤ÇÅϤµ¤ì¤ë¤È¡¤gengetopt¤Ï cmdline_parser_print_help()¤ò¸Æ¤Ó½Ð¤·¡¤¥Ð¥°Êó¹ð¤Î¹Ô¤¬É½¼¨¤µ¤ì¤Þ ¤¹¡¥--version|-V¤¬ÅϤµ¤ì¤ë¤È¤­¡¤ cmdline_parser_print_version()¤¬¸Æ¤Ó½Ð¤µ¤ì¡¤Ãøºî¸¢¤¬½ÐÎϤµ¤ì¤Þ¤¹¡¥ ¥¨¥é¡¼¤¬À¸¤¸¤¿¾ì¹ç¡¤²èÌ̤˥á¥Ã¥»¡¼¥¸¤¬½ÐÎϤµ¤ì¤Þ¤¹¡¥

$ ./gengetopt --zzzz
./gengetopt: unrecognized option `--zzzz'
Run gengetopt --help to see the list of options.

Next: , Previous: Basic Usage, Up: Top   [Contents][Index]