icinga

Icinga2 API client in Go
git clone https://git.olowe.co/icinga
Log | Files | Refs | README | LICENSE

crud.sh (603B)


      1 #!/bin/sh
      2 
      3 types="Host Service User HostGroup"
      4 
      5 head="// Code generated by $0 $@; DO NOT EDIT.
      6 
      7 package icinga
      8 
      9 import (
     10 	\"fmt\"
     11 	\"net/url\"
     12 )
     13 "
     14 
     15 args=`getopt o: $*`
     16 if test $? -ne 0
     17 then
     18 	echo "usage: lookupgen.sh [-o file]"
     19 	exit 2
     20 fi
     21 set -- $args
     22 while test "$#" -ne 0
     23 do
     24 	case "$1"
     25 	in
     26 		-o)
     27 			file="$2"; shift; shift;;
     28 		--)
     29 			shift; break;;
     30 	esac
     31 done
     32 
     33 if test -n "$file"
     34 then
     35 	echo "$head" > "$file"
     36 else
     37 	echo "$head"
     38 fi
     39 
     40 for t in $types
     41 do
     42 	if test -n "$file"
     43 	then
     44 		awk -v "type=$t" -f crud.awk crud.skel | gofmt >> "$file"
     45 	else
     46 		awk -v "type=$t" -f crud.awk crud.skel | gofmt
     47 	fi
     48 done