Merge branch 'master' of ssh://git.carlh.net/home/carl/git/cdist
[cdist.git] / cdist
diff --git a/cdist b/cdist
index 139968052bf63298b20b3b788443b4bf55f327df..0a13bff3de9983a8ea12fc027b34e43381e1027f 100755 (executable)
--- 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:
@@ -958,12 +970,19 @@ class Tree(object):
 
     def build_dependencies(self, options):
         for i in self.dependencies(options):
+            global args
+            if args.verbose:
+                print('Building a dependency of %s %s %s with %s' % (self.name, self.specifier, self.version, options))
             i[0].build(i[1])
 
     def build(self, options):
         if self.built:
             return
 
+        global args
+        if args.verbose:
+            print("* Building %s %s %s with %s" % (self.name, self.specifier, self.version, options))
+
         variables = copy.copy(self.target.variables)
 
         # Start with the options passed in
@@ -1030,6 +1049,8 @@ def main():
     parser.add_argument('--no-version-commit', help="use just tags for versioning, don't modify wscript, ChangeLog etc.", action='store_true')
     parser.add_argument('--option', help='set an option for the build (use --option key:value)', action='append')
     parser.add_argument('--ccache', help='use ccache', action='store_true')
+    parser.add_argument('--verbose', help='be verbose', action='store_true')
+    global args
     args = parser.parse_args()
 
     # Check for incorrect multiple parameters