zenu

Des menus dans votre terminal - retour accueil

git clone git://bebou.netlib.re/zenu
Log | Files | Refs | README |

build (932B)


      1 #! /usr/bin/env zsh
      2 
      3 usage() <<-% cat
      4 	usage:
      5 	* build a face (the file that becomes part of a menu)
      6 		$0 face file
      7 		$0 -f file
      8 	* build a script (the function to handle pressed keys)
      9 		$0 script file
     10 		$0 -f file
     11 %
     12 
     13 cmd="${1?command to run. -h for details}"
     14 :   "${2?file to parse. -h for details}"
     15 shift
     16 
     17 case "$cmd"
     18 in (-h|help|--help) usage
     19 ;; (face   | -f) sed -En '/^##/q;s/_(.)/\1/g;s/^/ /p' "$@"
     20 # Avoid Quoting hell (QH) with aliases:
     21 # with QH 
     22 ;; (script | -s) <<-% cat
     23 		$( sed -En '/^## *pre */,/^##/p' "$@" )
     24 		read -sk1 zenu_key
     25 		case "\$zenu_key"
     26 		in (\$'q') zenu--
     27 		$( sed -En '/^## *react */,/^##/p' "$@" )
     28 		esac 2> \$zenu_store/err
     29 	%
     30 ;; (emph| -e)
     31 	sed -En '/^##/q;s/(.*)_((.).*)/\3 \1\2 /;p' "$@" | awk '
     32 			{line[i++]=$0}
     33 			(l=length)>m {m=l}
     34 			END { for (i=0; i<until ; ++i) printf "%-*s\n", m, line[i] }
     35 		' until=$(cat $to/until.txt)
     36 ;; (*)
     37 	>& echo "$cmd isn't a valid command"
     38 	false
     39 esac
     40 
     41