address.sh does it's output as it should

master
Gandalf 2021-03-13 17:44:33 +01:00
parent 457367d373
commit 737b3fd402
2 changed files with 84 additions and 0 deletions

70
Adressen/address.sh Executable file
View File

@ -0,0 +1,70 @@
#! /bin/bash
# address takes two arguments: a flag what to do as $1 and a handle to handle as $2
H=$2
F=$1
O=false
LOC=""
COL=""
if [ $# -lt 2 ]
then
echo "Zu wenig Argumente"
exit 1
fi
if [ $# -gt 2 ]
then
echo "Ignoriere überschüssige Argumente"
fi
if [ $F = "-n" ]
then
COL=Name
O=true
fi
if [ $F = "-a" ]
then
COL=Anrede
O=true
fi
if [ $F = "-d" ]
then
COL=Adresse
O=true
fi
if [ $F = "-f" ]
then
# return fax number to be used by sipgate-cli
COL=FaxNr
O=true
fi
if [ $F = "-t" ]
then
COL=TelNr
O=true
fi
if [ $F = "-c" ]
then
COL=Closing
O=true
fi
if [ $F = "-p" ]
then
COL=parent
O=true
fi
if [ $O ]
then
LOC=$(head -1 Adressen.csv | tr ',' '\n' | nl |grep -w "$COL" | tr -d " " | awk -F " " '{print $1}') #calculating position of requested Col
grep "$H" Adressen.csv | cut -d "," -f$LOC | head -n 1 | sed 's/"//g'
#Returning requested column, making sure to return only one result (even though redundant results shouldn't be possible)
fi

View File

@ -74,6 +74,20 @@ Markdown-formatierte Übersicht. Oder ein anderes Format? An sich könnte er das
Holt sich die Aktenzeichen aus `DECKBLATT.csv`
#### `address.sh`
Führt durch die Eintragung in die Adressdatenbank oder gibt einzelne Werte aus selbiger zurück. (Zur Verwendung durch `sipgate-cli` zB)
```
./address.sh <flag> <handle>
```
Verfügbare Flags:
* `-f` gibt die Faxnummer zurück. Anwendung: `fax <Datei> $(address.sh -f <handle>)`
* `-t`: Telefonnummer
* `-p`: Parent Entity
* `-a`: Anrede
* `-d`: Adresse
* `-n`: Name
* `-e`: Editieren
* `-c`: Erzeugen eines Eintrags
Wir `<handle>` nicht angegeben, soll nach der aktuell zuständigen Stelle in einer `DECKBLATT.csv` gesucht werden.
#### `init.sh`
Führt durch die Anlage eines Deckblattes ~~und stellt sicher, dass die korrekte Gerichtshierarchie eingetragen ist~~.
#### `rechtsmittel.sh`