Skip to content

Commit

Permalink
Allow user to specify alternate wallet and config filenames as arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsand committed Jan 17, 2018
1 parent 5ee42eb commit 146d48b
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cryptop/cryptop.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

import requests
import requests_cache
import argparse

# GLOBALS!
BASEDIR = os.path.join(os.path.expanduser('~'), '.cryptop')
DATAFILE = os.path.join(BASEDIR, 'wallet.json')
CONFFILE = os.path.join(BASEDIR, 'config.ini')
CONFIG = configparser.ConfigParser()
COIN_FORMAT = re.compile('[A-Z]{2,5},\d{0,}\.?\d{0,}')

Expand Down Expand Up @@ -254,11 +253,30 @@ def mainc(stdscr):
global COLUMN
COLUMN = (COLUMN + 1) % len(SORTS)

# Allow user to specify wallet and config filenames as arguments
def handleargs():
global DATAFILE, CONFFILE
parser = argparse.ArgumentParser()
parser.add_argument("-w", "--wallet", type=str, help="Specify wallet filename")
parser.add_argument("-c", "--config", type=str, help="Specify config filename")
args = parser.parse_args()
if args.wallet:
DATAFILE = os.path.join(BASEDIR, args.wallet)
else:
DATAFILE = os.path.join(BASEDIR, 'wallet.json')
if args.config:
CONFFILE = os.path.join(BASEDIR, args.config)
else:
CONFFILE = os.path.join(BASEDIR, 'config.ini')

print ('Wallet path:', str(DATAFILE))
print ('Config path:', str(CONFFILE))

def main():
if os.path.isfile(BASEDIR):
sys.exit('Please remove your old configuration file at {}'.format(BASEDIR))
os.makedirs(BASEDIR, exist_ok=True)

handleargs()
global CONFIG
CONFIG = read_configuration(CONFFILE)
locale.setlocale(locale.LC_MONETARY, CONFIG['locale'].get('monetary', ''))
Expand Down

0 comments on commit 146d48b

Please sign in to comment.