Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: A Completion Function for FIGlet

Just a shameless plug for my xml to completion tools....
The figlet command doesn't have usage information in a format that is
usable by my tool.   There is simple usage information and there is a man
page.  Though if you created a GNU style usage/help screen like so (this
is based on the previously posted completion function and the man page).

    -c          center justify
    -k          use kerning
    -l          left justify
    -n          normal mode
    -o          let letters overlap
    -p          paragraph mode
    -r          right justify
    -s          smushed spacing
    -t          use terminal width
    -v          version
    -x          use default justification of font
    -D          use Deutsch character set
    -E          use English character set
    -L          left-to-right
    -N          clear controlfile list
    -R          right-to-left
    -S          smush letters together or else!
    -W          wide spacing
    -X          use default writing direction of font
    -w Width     output width (in columns)
    -d dir       Font Directory 
    -f change_font   Font 
    -C change_controlfile   Control file
    -I -1       Normal operation (default)
    -I -v       Version, copyright and usage information
    -I 0        Version, copyright and usage information
    -I 1        Version in integer format
    -I 2        Default font directory.
    -I 3        Name of font figlet would use
    -I 4        Output width in number columns.

And then giving a help2simple.pl command like so:
  help2simple.pl -c figlet -S -a message  \
    -x -c,-l,-r,-x \
    -x -t,-w -x -n,-p \
    -x -D,-E -x -N,-C \
    -x -S,-s,-k,-W,-o \
    -x -L,-R,-X \
    -x -v,-I < Figlet.help >! figlet_simple.xml

The -S says that all single dash flags are single letters.  The -x flag
says that the following comma separated list of flags are mutually exclusive.
The -a says that the first argument is a message.

The processing figlet_simple.xml with the XSLT script simple2long.xsl, and
then  arg.xsl you get a version of _figlet that looks like the following.
It still needs work, but it gets you part of the way and does some of
the book keeping for exclusion lists, backslashes on the help for the
constants for the -I flag.  And building a case statements for the "$state".
And it works as is, no problems with syntax errors.


#compdef figlet 
#Generated by
#   simple2long.xsl
#   args.xsl
#   For details see:
#       http://www.geocities.com/f_rosencrantz/xml_completion.htm

 local context state line
           typeset -A opt_args
	_arguments  \
		"(-r -l -x)-c[center justify]" \
		"(-S -s -o -W)-k[use kerning]" \
		"(-r -c -x)-l[left justify]" \
		"(-p)-n[normal mode]" \
		"(-k -S -s -W)-o[let letters overlap]" \
		"(-n)-p[paragraph mode]" \
		"(-c -l -x)-r[right justify]" \
		"(-k -S -o -W)-s[smushed spacing]" \
		"(-w)-t[use terminal width]" \
		"(-I)-v[version]" \
		"(-r -c -l)-x[use default justification of font]" \
		"(-E)-D[use Deutsch character set]" \
		"(-D)-E[use English character set]" \
		"(-X -R)-L[left-to-right]" \
		"(-C)-N[clear controlfile list]" \
		"(-L -X)-R[right-to-left]" \
		"(-k -s -o -W)-S[smush letters together or else!]" \
		"(-k -S -s -o)-W[wide spacing]" \
		"(-L -R)-X[use default writing direction of font]" \
		"(-t)-w:output width (in columns):->Width" \
		"-d:Font Directory:->dir" \
		"-f:Font:->change_font" \
		"(-N)-C:Control file:->change_controlfile" \
		"(-v)-I: :((-1\:Normal\ operation\ \(default\)\  -v\:Version,\ copyright\
and\ usage\ information\  0\:Version,\ copyright\ and\ usage\ information\ 
1\:Version\ in\ integer\ format\  2\:Default\ font\ directory.\  3\:Name\ of\
font\ figlet\ would\ use\  4\:Output\ width\ in\ number\ columns.\ ))" \
		"*:Handling Tag message:->message" \
           && return 0
case $state in

Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®

Messages sorted by: Reverse Date, Date, Thread, Author