Commits

Matteo Bertini committed 22dd1cc

Read comments from all the lines

Comments (0)

Files changed (1)

                            tuple(sorted(self.commands)),
                           ))
     def _parse_options(self):
-        args, others = self.parser.parse_known_args(" ".join([self.comment] + self.commands).split())
+        args, others = self.parser.parse_known_args(" ".join([self.comment]).split())
         if args.MKTARGETS is not None:
             args.INPLACE = args.CHECKEXISTS = args.MKTARGETS
         self._inplace = set(self.targets if (args.INPLACE == []) else (args.INPLACE or []))
         lines = iter(lines)
         c = 0
         for line in lines:
+            comment = []
             try:
                 c += 1
                 if line.find("#") > 0:
-                    line, comment = (l.strip() for l in line.split("#", 1))
-                else:
-                    comment = ""
+                    line, _comment = (l.strip() for l in line.split("#", 1))
+                    if _comment:
+                        comment += [_comment]
                 if not line:
                     continue
                 if ":" in line:
                     deps = dict((i.strip(), None) for i in deps.split())
                     #TODO: add support for multiline command
                     commands = [lines.next().strip()]
+                    comment = " ".join(comment)
                     yield BaseTask(targets, deps, comment, commands, c)
                     c += 1
             except: