diff options
Diffstat (limited to 'alg')
| -rwxr-xr-x | alg | 127 |
1 files changed, 123 insertions, 4 deletions
| @@ -6,7 +6,11 @@ | |||
| 6 | # Example: alg c UBL E - prints out all first algs for UBL-FDR-* | 6 | # Example: alg c UBL E - prints out all first algs for UBL-FDR-* |
| 7 | 7 | ||
| 8 | usage() { | 8 | usage() { |
| 9 | echo "Usage: alg [[edit] (c|e|w|x) [buffer] (1 letter|2 letters)]" | 9 | echo "Usage:" |
| 10 | echo "alg" | ||
| 11 | echo "alg edit (c|e|w|x) [buffer] (1 letter|2 letters)" | ||
| 12 | echo "alg export (c|e|w|x)" | ||
| 13 | echo "alg publish" | ||
| 10 | } | 14 | } |
| 11 | 15 | ||
| 12 | default_editor=vi | 16 | default_editor=vi |
| @@ -178,13 +182,128 @@ showall_x() { | |||
| 178 | done | 182 | done |
| 179 | } | 183 | } |
| 180 | 184 | ||
| 185 | export_csv_c() { | ||
| 186 | sorted_letters="d b c l n p m k z f j v w g a o e s r u t" | ||
| 187 | buffer="$cbuffer" | ||
| 188 | f="$basedir/corners/$buffer" | ||
| 189 | printf '"",' | ||
| 190 | for first in $sorted_letters; do | ||
| 191 | printf '"%s",' "$(corner $first)" | ||
| 192 | done | ||
| 193 | printf '\n' | ||
| 194 | for first in $sorted_letters; do | ||
| 195 | firstpiece="$(corner $first)" | ||
| 196 | printf '"%s",' "$firstpiece" | ||
| 197 | for second in $sorted_letters; do | ||
| 198 | g="$f/$firstpiece/$(corner $second)" | ||
| 199 | if [ "$first" = "$second" ] || [ ! -f "$g" ]; then | ||
| 200 | printf '"",' | ||
| 201 | else | ||
| 202 | printf '"%s",' "$(head -n 1 "$g")" | ||
| 203 | fi | ||
| 204 | done | ||
| 205 | printf '\n' | ||
| 206 | done | ||
| 207 | } | ||
| 208 | |||
| 209 | export_csv_e() { | ||
| 210 | sorted_letters="d c b n l p m k z f v j w g i a o e t r u s" | ||
| 211 | buffer="$ebuffer" | ||
| 212 | f="$basedir/edges/$buffer" | ||
| 213 | printf '"",' | ||
| 214 | for first in $sorted_letters; do | ||
| 215 | printf '"%s",' "$(edge $first)" | ||
| 216 | done | ||
| 217 | printf '\n' | ||
| 218 | for first in $sorted_letters; do | ||
| 219 | firstpiece="$(edge $first)" | ||
| 220 | printf '"%s",' "$firstpiece" | ||
| 221 | for second in $sorted_letters; do | ||
| 222 | g="$f/$firstpiece/$(edge $second)" | ||
| 223 | if [ "$first" = "$second" ] || [ ! -f "$g" ]; then | ||
| 224 | printf '"",' | ||
| 225 | else | ||
| 226 | printf '"%s",' "$(head -n 1 "$g")" | ||
| 227 | fi | ||
| 228 | done | ||
| 229 | printf '\n' | ||
| 230 | done | ||
| 231 | } | ||
| 232 | |||
| 233 | export_csv_w() { | ||
| 234 | sorted_letters="b d c n l p m k x z f v j w g i a o e t r u s" | ||
| 235 | buffer="$wbuffer" | ||
| 236 | f="$basedir/wings/$buffer" | ||
| 237 | printf '"",' | ||
| 238 | for first in $sorted_letters; do | ||
| 239 | printf '"%s",' "$(wing $first)" | ||
| 240 | done | ||
| 241 | printf '\n' | ||
| 242 | for first in $sorted_letters; do | ||
| 243 | firstpiece="$(wing $first)" | ||
| 244 | printf '"%s",' "$firstpiece" | ||
| 245 | for second in $sorted_letters; do | ||
| 246 | g="$f/$firstpiece/$(wing $second)" | ||
| 247 | if [ "$first" = "$second" ] || [ ! -f "$g" ]; then | ||
| 248 | printf '"",' | ||
| 249 | else | ||
| 250 | printf '"%s",' "$(head -n 1 "$g")" | ||
| 251 | fi | ||
| 252 | done | ||
| 253 | printf '\n' | ||
| 254 | done | ||
| 255 | } | ||
| 256 | |||
| 257 | export_csv_x() { | ||
| 258 | sorted_letters="d c b l n p m k x z f j v w g i a o e s r u t" | ||
| 259 | buffer="$xbuffer" | ||
| 260 | f="$basedir/xcenters/$buffer" | ||
| 261 | printf '"",' | ||
| 262 | for first in $sorted_letters; do | ||
| 263 | printf '"%s",' "$(xcenter $first)" | ||
| 264 | done | ||
| 265 | printf '\n' | ||
| 266 | for first in $sorted_letters; do | ||
| 267 | firstpiece="$(xcenter $first)" | ||
| 268 | printf '"%s",' "$firstpiece" | ||
| 269 | for second in $sorted_letters; do | ||
| 270 | g="$f/$firstpiece/$(xcenter $second)" | ||
| 271 | if [ "$first" = "$second" ] || [ ! -f "$g" ]; then | ||
| 272 | printf '"",' | ||
| 273 | else | ||
| 274 | printf '"%s",' "$(head -n 1 "$g")" | ||
| 275 | fi | ||
| 276 | done | ||
| 277 | printf '\n' | ||
| 278 | done | ||
| 279 | } | ||
| 280 | |||
| 181 | run() { | 281 | run() { |
| 182 | if [ "$1" = "edit" ]; then | 282 | case "$1" in |
| 283 | edit) | ||
| 183 | editor="$default_editor" | 284 | editor="$default_editor" |
| 184 | shift | 285 | shift |
| 185 | else | 286 | ;; |
| 287 | export) | ||
| 288 | if [ "$2" = "all" ]; then | ||
| 289 | mkdir -p bldsheets | ||
| 290 | export_csv_c > bldsheets/corners.csv | ||
| 291 | export_csv_e > bldsheets/edges.csv | ||
| 292 | export_csv_w > bldsheets/wings.csv | ||
| 293 | export_csv_x > bldsheets/xcenters.csv | ||
| 294 | echo "Sheets exported to bldsheets" | ||
| 295 | return | ||
| 296 | fi | ||
| 297 | #TODO add option for alternative buffers | ||
| 298 | [ "$2" != "c" ] && [ "$2" != "e" ] && \ | ||
| 299 | [ "$2" != "w" ] && [ "$2" != "x" ] && usage && return | ||
| 300 | export_csv_$2 | ||
| 301 | return | ||
| 302 | ;; | ||
| 303 | *) | ||
| 186 | editor="cat" | 304 | editor="cat" |
| 187 | fi | 305 | ;; |
| 306 | esac | ||
| 188 | 307 | ||
| 189 | type="$1" | 308 | type="$1" |
| 190 | if [ -z "$3" ]; then | 309 | if [ -z "$3" ]; then |
