#! /bin/sh # -*- Mode: Shell-script -*- # ---------------------------------------------------------------------- # usage.test --- test all the ways usage text can be printed. # ## Time-stamp: "2007-07-04 10:11:07 bkorb" # Author: Bruce Korb ## ## This file is part of AutoOpts, a companion to AutoGen. ## AutoOpts is free software. ## AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved ## ## AutoOpts is available under any one of two licenses. The license ## in use must be one of these two and the choice is under the control ## of the user of the license. ## ## The GNU Lesser General Public License, version 3 or later ## See the files "COPYING.lgplv3" and "COPYING.gplv3" ## ## The Modified Berkeley Software Distribution License ## See the file "COPYING.mbsd" ## ## These files have the following md5sums: ## ## 239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3 ## fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3 ## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd # # $Id: usage.test,v 4.6 2007/07/04 21:36:40 bkorb Exp $ # ---------------------------------------------------------------------- . ./defs # # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # # ============= usage_LGFRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGFRA.hlp' test_usage_LGFRA - Checkout usage_LGFRA Options USAGE: usage_LGFRA { - [] | --[{=| }] }... \ cmd-arg ... X X -L, --check-dirs=str Checkout directory list X --show-defs[=arg] Show the definition tree X -?, --help Display usage information and exit X -!, --more-help Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage should be in GNU style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_LGFRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGFRp.hlp' test_usage_LGFRp - Checkout usage_LGFRp Options USAGE: usage_LGFRp { - | -- }... cmd-arg ... X X -L, --check-dirs Checkout directory list X --show-defs Show the definition tree X -?, --help Display usage information and exit X -!, --more-help Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage should be in GNU style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_LGFoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGFoA.hlp' test_usage_LGFoA - Checkout usage_LGFoA Options USAGE: usage_LGFoA [ - [] | --[{=| }] ]... \ cmd-arg ... X X -L, --check-dirs=str Checkout directory list X --show-defs[=arg] Show the definition tree X -?, --help Display usage information and exit X -!, --more-help Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage should be in GNU style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_LGFop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGFop.hlp' test_usage_LGFop - Checkout usage_LGFop Options USAGE: usage_LGFop [ - | -- ]... cmd-arg ... X X -L, --check-dirs Checkout directory list X --show-defs Show the definition tree X -?, --help Display usage information and exit X -!, --more-help Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage should be in GNU style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_LGsRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGsRA.hlp' test_usage_LGsRA - Checkout usage_LGsRA Options USAGE: usage_LGsRA { --[{=| }] }... cmd-arg ... X X --check-dirs=str Checkout directory list X --show-defs[=arg] Show the definition tree X --help Display usage information and exit X --more-help Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage should be in GNU style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_LGsRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGsRp.hlp' test_usage_LGsRp - Checkout usage_LGsRp Options USAGE: usage_LGsRp { -- }... cmd-arg ... X X --check-dirs Checkout directory list X --show-defs Show the definition tree X --help Display usage information and exit X --more-help Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage should be in GNU style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_LGsoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGsoA.hlp' test_usage_LGsoA - Checkout usage_LGsoA Options USAGE: usage_LGsoA [ --[{=| }] ]... cmd-arg ... X X --check-dirs=str Checkout directory list X --show-defs[=arg] Show the definition tree X --help Display usage information and exit X --more-help Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage should be in GNU style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_LGsop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LGsop.hlp' test_usage_LGsop - Checkout usage_LGsop Options USAGE: usage_LGsop [ -- ]... cmd-arg ... X X --check-dirs Checkout directory list X --show-defs Show the definition tree X --help Display usage information and exit X --more-help Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage should be in GNU style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_LaFRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LaFRA.hlp' test_usage_LaFRA - Checkout usage_LaFRA Options USAGE: usage_LaFRA { - [] | --[{=| }] }... \ cmd-arg ... X Flg Arg Option-Name Req? Description X -L Str check-dirs YES Checkout directory list X opt show-defs opt Show the definition tree X -? no help opt Display usage information and exit X -! no more-help opt Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage is in AutoOpts traditional style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_LaFRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LaFRp.hlp' test_usage_LaFRp - Checkout usage_LaFRp Options USAGE: usage_LaFRp { - | -- }... cmd-arg ... X Flg Arg Option-Name Req? Description X -L no check-dirs YES Checkout directory list X no show-defs opt Show the definition tree X -? no help opt Display usage information and exit X -! no more-help opt Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage is in AutoOpts traditional style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_LaFoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LaFoA.hlp' test_usage_LaFoA - Checkout usage_LaFoA Options USAGE: usage_LaFoA [ - [] | --[{=| }] ]... \ cmd-arg ... X Flg Arg Option-Name Description X -L Str check-dirs Checkout directory list X opt show-defs Show the definition tree X -? no help Display usage information and exit X -! no more-help Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage is in AutoOpts traditional style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_LaFop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LaFop.hlp' test_usage_LaFop - Checkout usage_LaFop Options USAGE: usage_LaFop [ - | -- ]... cmd-arg ... X Flg Arg Option-Name Description X -L no check-dirs Checkout directory list X no show-defs Show the definition tree X -? no help Display usage information and exit X -! no more-help Extended usage information passed thru pager X Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. X Long and short (flag) options are accepted. Usage is in AutoOpts traditional style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_LasRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LasRA.hlp' test_usage_LasRA - Checkout usage_LasRA Options USAGE: usage_LasRA { --[{=| }] }... cmd-arg ... X Arg Option-Name Req? Description X Str check-dirs YES Checkout directory list X opt show-defs opt Show the definition tree X no help opt Display usage information and exit X no more-help opt Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage is in AutoOpts traditional style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_LasRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LasRp.hlp' test_usage_LasRp - Checkout usage_LasRp Options USAGE: usage_LasRp { -- }... cmd-arg ... X Arg Option-Name Req? Description X no check-dirs YES Checkout directory list X no show-defs opt Show the definition tree X no help opt Display usage information and exit X no more-help opt Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage is in AutoOpts traditional style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_LasoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_LasoA.hlp' test_usage_LasoA - Checkout usage_LasoA Options USAGE: usage_LasoA [ --[{=| }] ]... cmd-arg ... X Arg Option-Name Description X Str check-dirs Checkout directory list X opt show-defs Show the definition tree X no help Display usage information and exit X no more-help Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage is in AutoOpts traditional style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_Lasop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_Lasop.hlp' test_usage_Lasop - Checkout usage_Lasop Options USAGE: usage_Lasop [ -- ]... cmd-arg ... X Arg Option-Name Description X no check-dirs Checkout directory list X no show-defs Show the definition tree X no help Display usage information and exit X no more-help Extended usage information passed thru pager X Options are specified by single or double hyphens and their name. X Only long options are accepted. Usage is in AutoOpts traditional style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_sGFRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGFRA.hlp' test_usage_sGFRA - Checkout usage_sGFRA Options USAGE: usage_sGFRA { - [] }... cmd-arg ... X X -L str Checkout directory list X -s [arg] Show the definition tree X -? Display usage information and exit X -! Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage should be in GNU style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_sGFRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGFRp.hlp' test_usage_sGFRp - Checkout usage_sGFRp Options USAGE: usage_sGFRp { - }... cmd-arg ... X X -L Checkout directory list X -s Show the definition tree X -? Display usage information and exit X -! Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage should be in GNU style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_sGFoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGFoA.hlp' test_usage_sGFoA - Checkout usage_sGFoA Options USAGE: usage_sGFoA [ - [] ]... cmd-arg ... X X -L str Checkout directory list X -s [arg] Show the definition tree X -? Display usage information and exit X -! Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage should be in GNU style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_sGFop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGFop.hlp' test_usage_sGFop - Checkout usage_sGFop Options USAGE: usage_sGFop [ - ]... cmd-arg ... X X -L Checkout directory list X -s Show the definition tree X -? Display usage information and exit X -! Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage should be in GNU style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_sGsRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGsRA.hlp' test_usage_sGsRA - Checkout usage_sGsRA Options USAGE: usage_sGsRA { [{=| }] }... X X check-dirs=str Checkout directory list X show-defs[=arg] Show the definition tree X help Display usage information and exit X more-help Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage should be in GNU style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_sGsRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGsRp.hlp' test_usage_sGsRp - Checkout usage_sGsRp Options USAGE: usage_sGsRp { }... X X check-dirs Checkout directory list X show-defs Show the definition tree X help Display usage information and exit X more-help Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage should be in GNU style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_sGsoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGsoA.hlp' test_usage_sGsoA - Checkout usage_sGsoA Options USAGE: usage_sGsoA [ [{=| }] ]... X X check-dirs=str Checkout directory list X show-defs[=arg] Show the definition tree X help Display usage information and exit X more-help Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage should be in GNU style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_sGsop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sGsop.hlp' test_usage_sGsop - Checkout usage_sGsop Options USAGE: usage_sGsop [ ]... X X check-dirs Checkout directory list X show-defs Show the definition tree X help Display usage information and exit X more-help Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage should be in GNU style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_saFRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_saFRA.hlp' test_usage_saFRA - Checkout usage_saFRA Options USAGE: usage_saFRA { - [] }... cmd-arg ... X Flg Arg Option-Name Req? Description X -L Str check-dirs YES Checkout directory list X -s opt show-defs opt Show the definition tree X -? no help opt Display usage information and exit X -! no more-help opt Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage is in AutoOpts traditional style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_saFRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_saFRp.hlp' test_usage_saFRp - Checkout usage_saFRp Options USAGE: usage_saFRp { - }... cmd-arg ... X Flg Arg Option-Name Req? Description X -L no check-dirs YES Checkout directory list X -s no show-defs opt Show the definition tree X -? no help opt Display usage information and exit X -! no more-help opt Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage is in AutoOpts traditional style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_saFoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_saFoA.hlp' test_usage_saFoA - Checkout usage_saFoA Options USAGE: usage_saFoA [ - [] ]... cmd-arg ... X Flg Arg Option-Name Description X -L Str check-dirs Checkout directory list X -s opt show-defs Show the definition tree X -? no help Display usage information and exit X -! no more-help Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage is in AutoOpts traditional style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_saFop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_saFop.hlp' test_usage_saFop - Checkout usage_saFop Options USAGE: usage_saFop [ - ]... cmd-arg ... X Flg Arg Option-Name Description X -L no check-dirs Checkout directory list X -s no show-defs Show the definition tree X -? no help Display usage information and exit X -! no more-help Extended usage information passed thru pager X X Only short (flag) options are accepted. Usage is in AutoOpts traditional style. There are no required options. No options require arguments. SHAR_EOF # ============= usage_sasRA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sasRA.hlp' test_usage_sasRA - Checkout usage_sasRA Options USAGE: usage_sasRA { [{=| }] }... X Arg Option-Name Req? Description X Str check-dirs YES Checkout directory list X opt show-defs opt Show the definition tree X no help opt Display usage information and exit X no more-help opt Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage is in AutoOpts traditional style. The check-dirs option is required. Some options require arguments. SHAR_EOF # ============= usage_sasRp.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sasRp.hlp' test_usage_sasRp - Checkout usage_sasRp Options USAGE: usage_sasRp { }... X Arg Option-Name Req? Description X no check-dirs YES Checkout directory list X no show-defs opt Show the definition tree X no help opt Display usage information and exit X no more-help opt Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage is in AutoOpts traditional style. The check-dirs option is required. No options require arguments. SHAR_EOF # ============= usage_sasoA.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sasoA.hlp' test_usage_sasoA - Checkout usage_sasoA Options USAGE: usage_sasoA [ [{=| }] ]... X Arg Option-Name Description X Str check-dirs Checkout directory list X opt show-defs Show the definition tree X no help Display usage information and exit X no more-help Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage is in AutoOpts traditional style. There are no required options. Some options require arguments. SHAR_EOF # ============= usage_sasop.hlp ============== sed 's/^X//' << 'SHAR_EOF' > 'usage_sasop.hlp' test_usage_sasop - Checkout usage_sasop Options USAGE: usage_sasop [ ]... X Arg Option-Name Description X no check-dirs Checkout directory list X no show-defs Show the definition tree X no help Display usage information and exit X no more-help Extended usage information passed thru pager X All arguments are named options. X All command line arguments must be named options. Usage is in AutoOpts traditional style. There are no required options. No options require arguments. SHAR_EOF # # # # # # # # # # DEFINITIONS FILES # # # # # # # # # nl=' ' emit_defs() { exec 4> $1.def cat >&4 <<- _EOF_ AutoGen Definitions options; prog-name = test_$1; prog-title = "Checkout $1 Options"; config-header = 'config.h'; test-main; _EOF_ cmd_arg="argument = 'cmd-arg ...';" if ${long_opts} then echo "long-opts;" >&4 if ${flag_opts} then detail="Long and short (flag) options are accepted." else detail="Only long options are accepted." ; fi else if ${flag_opts} then detail="Only short (flag) options are accepted." else detail="All command line arguments must be named options." cmd_arg='' fi fi if ${gnu_usage} then echo "gnu-usage;" >&4 detail="${detail}${nl}Usage should be in GNU style." else detail="${detail}${nl}Usage is in AutoOpts traditional style." fi cat >&4 <<- _EOF_ ${cmd_arg} flag = { name = check_dirs; descrip = "Checkout directory list"; _EOF_ if ${flag_opts} then echo " value = L;" >&4 fi if ${req_opts} then echo " min = '1';" >&4 detail="${detail}${nl}The check-dirs option is required." else detail="${detail}${nl}There are no required options." fi if ${arg_opts} then echo " arg-type = string;" >&4 echo " arg-name = dir;" >&4 detail="${detail}${nl}Some options require arguments." else detail="${detail}${nl}No options require arguments." fi cat >&4 <<- _EOF_ }; flag = { name = show_defs; descrip = "Show the definition tree"; _EOF_ if ${flag_opts} then ${long_opts} || echo " value = s;" >&4 fi if ${arg_opts} then echo " arg-type = number;" >&4 echo " arg-name = depth;" >&4 echo " arg-optional;" >&4 fi echo "};" >&4 echo "detail = '${detail}';" >&4 exec 4>&- } test_list="" tname=${testname} for long_opts in true false do ${long_opts} && lname=L || lname=s for gnu_usage in true false do ${gnu_usage} && uname="${lname}G" || uname="${lname}a" for flag_opts in true false do ${flag_opts} && fname="${uname}F" || fname="${uname}s" if ${long_opts} then helpstr=--help elif ${flag_opts} then helpstr='-?' else helpstr=help fi for req_opts in true false do ${req_opts} && rname="${fname}R" || rname="${fname}o" for arg_opts in true false do ${arg_opts} && name="${rname}A" || name="${rname}p" testname=${tname}_${name} emit_defs ${testname} test_list="${test_list} ${testname}" ${AG_L} ${testname}.def || \ failure "AutoGen could not process $testname" compile ${helpstr} cmp -s ${testname}.help ${testname}.hlp || \ failure "FAILED ${testname} hlp -> help `diff ${testname}.hlp ${testname}.help`" if ${gnu_usage} then f=`echo ${testname} | sed "s/\\(${tname}_.\\).\\(.*\\)/\\1a\\2/"` sed "s/${f}/${testname}/g;\ s/is in AutoOpts traditional/should be in GNU/" ${f}.hlp > \ ${testname}.alt.hlp AUTOOPTS_USAGE=autoopts ./${testname} ${helpstr} > \ ${testname}.alt.help else f=`echo ${testname} | sed "s/\\(${tname}_.\\).\\(.*\\)/\\1G\\2/"` sed "s/${f}/${testname}/g;\ s/should be in GNU/is in AutoOpts traditional/" ${f}.hlp > \ ${testname}.alt.hlp AUTOOPTS_USAGE=gnu ./${testname} ${helpstr} > \ ${testname}.alt.help fi cmp -s ${testname}.alt.help ${testname}.alt.hlp || \ failure "FAILED ${testname} alt [$f] hlp -> help `diff ${testname}.alt.help ${testname}.alt.hlp`" done done done done done cleanup ## Local Variables: ## Mode: shell-script ## indent-tabs-mode: nil ## sh-indentation: 2 ## End: # end of usage.test