README.md (4085B)
1 ``` 2 _ _ _ _ _ 3 (_)(_)(_)(_)(_) 4 _(_)_ _ _ _ _ _ _ _ _ _ _ _ _ 5 _(_) (_) (_) (_)(_)(_)(_)_ (_)(_)(_)(_)(_)_ _ (_)(_) 6 _(_) (_) (_) (_) (_(_) _ _ _ (_)(_)(_) 7 _(_) (_) (_) (_) (_(_)(_)(_)(_)(_)(_) 8 _ (_) _ _ (_)_ _ _(_)_(_) _ _ _(_(_)_ _ _ _ (_) 9 (_)(_)(_)(_)(_)(_)(_)(_) (_(_)(_)(_)(_) (_)(_)(_)(_) (_) 10 (_) 11 (_) 12 ``` 13 14 **Z**sh **U**ltimate **P**rogrammer's **E**xtensions **R**efurbished 15 16 # Introduction 17 18 Zuper is a minimalist library of extensions for Zsh programming, 19 because believe it or not Zsh is so slick and powerful that it can be 20 used as a programming language. 21 22 # Features 23 24 - key/value store on files mapped to associative arrays 25 - consul k/v integration using native get/set over ztcp 26 - nifty messaging using colors and intl support (gettext) 27 - procedural flow debugging functions and variable monitor 28 - clean exit and destructors registration 29 - improved temp file handling 30 - more to come... 31 32 # Requirements 33 34 Zuper requires the following programs to be installed: 35 36 ``` 37 zsh curl sed awk hexdump 38 ``` 39 40 # Usage 41 42 Documentation is still lacking, however to use Zuper in Zsh scripts 43 one must first source its main library `zuper`, then declare global 44 variables and arrays, then source `zuper.init` and at the end of the 45 program call `endgame` for a clean exit. Example test program: 46 47 ```zsh 48 #!/usr/bin/env zsh 49 50 # switch on debugging output 51 DEBUG=1 52 53 # switch logging into test.log 54 LOG=test.log 55 56 ##### INIT 57 # load our zuper library 58 source zuper 59 # declare a custom global variable 60 vars+=(myvar) 61 # assign a default value to our global variable 62 myvar=${myvar:-ok} 63 # declare a global associative map 64 maps+=(mymap) 65 # conclude the init phase 66 source zuper.init 67 ##### 68 69 # register the zdump debug function to be executed on exit 70 destruens+=(zdump) 71 72 73 # declare a custom function to print it out 74 testfun() { 75 # register the function in the debug flow 76 fn "testfun" 77 # print out with nice green colors 78 notice "Custom var: $myvar" 79 # create a tempfile 80 ztmp && mytmp=$ztmpfile 81 # put the value into the tempfile 82 print $myvar >> $mytmp 83 # print out the path to the tempfile 84 act "Temp file: $mytmp" 85 # print out the contents of the tempfile 86 act "Content: `cat $mytmp`" 87 # the tempfile will be deleted in endgame() 88 # but can also be delete earlier here, optionally 89 } 90 91 92 # call our custom function 93 testfun 94 95 # we use words and their md5 96 mymap=( 97 lorem f737a087bca81f69a6048ec744c73e41 98 ipsum 02063b9bf9d6e15ad61226fa4584aae0 99 dolor 5f20730ddc7a1fedbf265358f0ce4f26 100 ) 101 102 # save the map into a file 103 zkv.save mymap test.map 104 105 # free the map 106 mymap=() 107 108 # re-declare the map 109 typeset -A mymap 110 # re-load saved contents 111 zkv.load test.map 112 # dump contents 113 for i in ${(k)mymap}; do 114 print "$i \t ${mymap[$i]}" 115 done 116 117 # end of the program (will call destructors) 118 ``` 119 120 121 # Deployment 122 123 Here we reference applications where zuper is used succesfully: 124 125 - Devuan Simple Development Toolkit https://git.devuan.org/groups/sdk 126 - Dowse IoT awareness OS http://dyne.org/software/dowse 127 - Jaro Mail terminal email http://dyne.org/software/jaro-mail 128 129 If you use it, let us know! http://dyne.org/contact 130 131 # License 132 133 Zuper is designed, developed and maintained by Denis Roio <jaromil@dyne.org> 134 135 Zuper is Copyright (C) 2015 by the Dyne.org foundation 136 137 This source code is free software; you can redistribute it and/or 138 modify it under the terms of the GNU Public License as published by 139 the Free Software Foundation; either version 3 of the License, or (at 140 your option) any later version. 141 142 This source code is distributed in the hope that it will be useful, 143 but WITHOUT ANY WARRANTY; without even the implied warranty of 144 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer to 145 the GNU Public License for more details. 146 147 You should have received a copy of the GNU Public License along with 148 this source code; if not, write to: Free Software Foundation, Inc., 149 675 Mass Ave, Cambridge, MA 02139, USA.