From 23edf54b665a4fd5ca2fbb55d6054ffe177c30be Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 21 Aug 2020 01:57:41 +0300 Subject: [PATCH] - Add stock holdings as json in 'data' dir. - Added data/ folder to gitignore. Signed-off-by: HeshamTB --- .gitignore | 2 ++ add | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 add diff --git a/.gitignore b/.gitignore index 480dcf6..8ba2b63 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +#user application folders raw/ +data/ diff --git a/add b/add new file mode 100755 index 0000000..28484fe --- /dev/null +++ b/add @@ -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 \"\" " + 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