#!/usr/local/bin/gawk -E # Process a name. Basically this: # # ./process -n "Clarence Erwin McClung" -p 0501-0750 # # runs the command: # # ./wi.csh -n "Clarence Erwin McClung" -p 0501-0750 > meta/births1870.0501-0750/tc.in/"Clarence Erwin McClung" # # Layer is needed for backwards compatible with .csh script and Project[""] directories # @include "init.awk" @include "library.awk" #@include "getopt.awk" BEGIN { Optind = Opterr = 1 while ((C = getopt(ARGC, ARGV, "sn:p:")) != -1) { opts++ if(C == "p") # -p Use project name. Defaults to what's in project.cfg pid = verifypid(Optarg) if(C == "n") # -n Name to process. Required. name = verifyval(Optarg) if(C == "s") # -s Show generated wi command but don't run process type = "show" if(C == "h") { # -h Help usage() exit } } if(opts == "" || name == "") { usage() exit } setProject(pid) # library.awk .. load Project[] paths via project.cfg # if -p not given, use default noted in project.cfg run(name) } function run(name, command) { # If name ends in "," then a Windows-mounted FS won't see it. # Convert to ~ then convert back later where needed fname = name if(fname ~ /[.]$/) sub(/[.]$/, "~", fname) # ./wi.csh -n "Clarence Erwin McClung" > meta/births1870.0501-0750/tc.in/"Clarence Erwin McClung" command = Exe["wi"] " -n " shquote(name) " -p " Project["id"] " > " Project["tcin"] shquote(fname) if(type == "show") print command else print sys2var(command) } function usage() { print "" print "Process - run wi.csh for a single name." print "" print "Usage:" print " -p Project name. Defaults to default.id in project.cfg" print " -n Name to process" print " -h Help" print "" print "Example: process -n \"Charles Dickens\"" print "" }