- Add stock holdings as json in 'data' dir.

- Added data/ folder to gitignore.

	Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-08-21 01:57:41 +03:00
parent 4702263d0a
commit 23edf54b66
Signed by: Hesham
GPG Key ID: 74876157D199B09E
2 changed files with 20 additions and 0 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
#user application folders
raw/ raw/
data/

18
add Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# Copyright (C) 2020 - Hesham Banafa
# 20 Aug 2020 - H.B.
#Add a stock to protfolio
if (($# != 5)); then
echo "Usage: add <code> \"<name>\" <cost> <quantity> <current>"
exit 1
fi
mkdir -p data
json=$(echo "{\"code\": $1, \"name\": \"$2\", \"cost\": $3, \"quantity\": $4, \"current\": $5}" | jq .)
if [ -n "$json" ]; then
echo $json | jq . > data/$1.json
else
exit 1
fi
exit 0