groff
またはtroff
を使用することは過剰です。 Decently layed outed printf()
の書式設定で十分です。ヘルプメッセージを体系的にレイアウトすると、管理が容易です。私のプログラムの中で最も複雑なオプションは次のとおりです。
static const char optlist[] = "a:cd:e:f:ghi:o:p:st:u:vxyz:A:BCD:E:F:G:HIJL:M:N:O:PQ:RS:TUVX:YZ:";
static const char usestr[] =
"[-cghsvxyY] [-d dbase] [-f file] [-e 'SQL stmt'] ['SQL stmt' ...]\n"
"Other options: [-CJPRU][-BHITV][-D delim][-E escape][-Q quote][-F format]\n"
" [-A date][-i file][-o file][-L qlimit][-N number][-M FIFO]\n"
" [-Z debug][-G eor][-t table][-p password][-u username]\n"
" [-a ibase][-X record=rectag,recset=settag,header=hdrtag]\n"
" [-O orderby][-S skip][-z number]\n"
"NB: -h gives more help!";
static const char fullhelp[] =
"\nOption summary:\n"
" -a ibase - input base (default 0; set to 10 for fields with leading zeroes)\n"
" -c - continue after errors\n"
" -d dbase - select database\n"
" -e 'SQL stmt' - execute SQL command\n"
" -f file - input file for SQLCMD\n"
" -g - debugging mode (single-step commands)\n"
" -h - print this message\n"
" -i file - input file for SQLRELOAD\n"
" -o file - output file for SQLUNLOAD\n"
" -p password - password for connection (beware security implications!)\n"
" -s - silent mode\n"
" -t table - name of table (for SQLRELOAD or SQLUNLOAD)\n"
" -u username - username for connection (beware security implications!)\n"
" -v - verbose mode\n"
" -x - trace mode\n"
" -y - enable history\n"
" -z number - set debugging level for syntax and lexical analyzers\n"
" -A date - set date format (eg dd-mm-yyyy for $DBDATE=dmy4-)\n"
" -B - operate in benchmark mode (implies -x and times SQL)\n"
" -C - operate as SQLCMD\n"
" -D delim - set field delimiter (default $DBDELIMITER or pipe)\n"
" -E escape - set escape character (default $DBESCAPE or backslash)\n"
" -F format - set output format (default SELECT; alternatives include:\n"
" UNLOAD, FIXED, FIXSEP, FIXDEL, CSV, XML, HTML)\n"
" -G eor - set EOR (end of record) character string (default $DBNEWLINE or newline)\n"
" -H - include column headings in output\n"
" -I - interactive mode (after executing command line)\n"
" -J - simulate isql/dbaccess; accept [database|-] [script|-]\n"
" -L qlimit - limit on number of rows returned by query\n"
" -M FIFO - monitor FIFO for input commands\n"
" -N number - size of transaction under RELOAD\n"
" (default 1024; 0 means no sub-transactions)\n"
" -O col1,... - order by these columns (SQLUNLOAD)\n"
" -P - operate as SQLUPLOAD (not implemented yet)\n"
" -Q quote - set quote character (default $DBQUOTE or double quote)\n"
" -R - operate as SQLRELOAD\n"
" -S skip - initial rows to skip (SQLRELOAD)\n"
" -T - include column types in output\n"
" -U - operate as SQLUNLOAD\n"
" -V - print version and exit\n"
" -X xmloptions - configure the XML output\n"
" recset='recsettag',record='recordtag',header='headertag'\n"
" -Y - do not enable history, even in interactive mode\n"
" -Z debug - set debugging level (SQLCMD must be compiled with debugging enabled)\n"
;
はい、長いオプションの前には長いオプションを使う必要があります。
いいですね。どうもありがとう!私はちょうど 'stdlib'か何かに隠された秘密の' make_nice_looking_help() '関数がないことを確認したかったのです。 ;) – Michael
'libpopt'にはこのような機能があります。あなたが[バグのいくつかを修正してください](http://homepage.ntlworld.com./jonathan.deboynepollard/Softwares/libpopt.html)、 '--help'テキストを単語ラップすることさえあります。 – JdeBP