From 4ed9d54c69f4142d0f7308cd99f8e17d88e49b1b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 23 Feb 2020 19:44:11 +0100 Subject: [PATCH] Make template config file if none exists. --- cdist | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cdist b/cdist index 1399680..71ab475 100755 --- a/cdist +++ b/cdist @@ -114,6 +114,18 @@ class Config: Option('flatpak_state_dir'), Option('parallel', multiprocessing.cpu_count()) ] + config_dir = '%s/.config' % os.path.expanduser('~') + if not os.path.exists(config_dir): + os.mkdir(config_dir) + config_file = '%s/cdist' % config_dir + if not os.path.exists(config_file): + f = open(config_file, 'w') + for o in self.options: + print('# %s ' % o.key, file=f) + f.close() + print('Template config file written to %s; please edit and try again.' % config_file, file=sys.stderr) + sys.exit(1) + try: f = open('%s/.config/cdist' % os.path.expanduser('~'), 'r') while True: -- 2.30.2