stew

a monorepo of some sort
git clone git://git.nsmpr.xyz/stew.git
Log | Files | Refs

wdb2tl (710B)


      1 #!/bin/rc
      2 # converts wdb entry from dir format to new tablist format
      3 
      4 rfork e
      5 
      6 
      7 wdb=/n/wdb/data
      8 uuid=$1
      9 dir=$"wdb/$"uuid
     10 
     11 test -d $"dir || { echo 'no such dir' $dir; exit 'bad uuid'}
     12 
     13 fn fail {
     14 	if (test '!' -f $1) {
     15 		echo 'fail' $1
     16 		exit 'fail'
     17 	}
     18 }
     19 
     20 fn wprint1 {
     21 	field=$1
     22 	file=$"dir/$"field
     23 	fail $"file
     24 	value=`{read $"file}
     25 	echo $"field^' \'^$"value
     26 	# read $"file
     27 }
     28 
     29 fn wprints {
     30 	field=$1
     31 	file=$"dir^'/'^$"field
     32 	fail $"file
     33 	echo $"field
     34 	awk '{printf("\t\\%s\n", $0)}' $"file
     35 }
     36 
     37 fn wtest {
     38 	file=$dir/$1
     39 	echo testing $file
     40 	fail $file
     41 	echo ok $file
     42 }
     43 
     44 test -n $"uuid || {echo 'no uuid'; exit 'no uuid'}
     45 
     46 wprints name
     47 wprint1 tags
     48 wprint1 type
     49 wprint1 status
     50 test -f $dir/extra && wprints extra