35 lines
1.0 KiB
Bash
Executable File
35 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright (C) 2020 Hesham Banafa
|
|
|
|
#This file is part of stonks.
|
|
|
|
# stonks is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# any later version.
|
|
#
|
|
# stonks is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with stonks. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
# 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
|