First run config info (#273)

* Show default options and config path when running for the first time

* Remove unnecessary global
This commit is contained in:
Linus Groh
2018-04-24 14:01:47 +02:00
committed by Ritiek Malhotra
parent 4eb4628128
commit a1b4266d08

View File

@@ -1,4 +1,6 @@
from core import internals
from core import internals, const
log = const.log
import logging
import yaml
@@ -48,10 +50,17 @@ def get_config(config_file):
with open(config_file, 'r') as ymlfile:
cfg = yaml.load(ymlfile)
except FileNotFoundError:
log.info('Writing default configuration to {0}:'.format(config_file))
with open(config_file, 'w') as ymlfile:
yaml.dump(default_conf, ymlfile, default_flow_style=False)
cfg = default_conf
for line in yaml.dump(default_conf['spotify-downloader'], default_flow_style=False).split('\n'):
if line.strip():
log.info(line.strip())
log.info('Please note that command line arguments have higher priority '
'than their equivalents in the configuration file')
return cfg['spotify-downloader']