- 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:
parent
4702263d0a
commit
23edf54b66
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
#user application folders
|
||||
raw/
|
||||
data/
|
||||
|
18
add
Executable file
18
add
Executable 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
|
Loading…
Reference in New Issue
Block a user