summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-02-23 19:44:11 +0100
committerCarl Hetherington <cth@carlh.net>2020-02-23 19:44:11 +0100
commit4ec5d0ed0f595309cb150201c87d25d17c62f099 (patch)
treed97012dfdbe724dd964e36c1083a661ad4b55a5a
parentaca0aa741e53b3ca3e884be1cd863acbb12f1bb5 (diff)
Make template config file if none exists.
-rwxr-xr-xcdist12
1 files changed, 12 insertions, 0 deletions
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: