#!/usr/bin/env python


import git
from tagged_document import TaggedDocument
from source_document import SourceDocument
import logging
import optparse
import sys

class Processor(object):
    
    def __init__(self, source_path, tagged_path, source_extensions=["txt"], tagged_extensions=["swift"], language=None):
        assert isinstance(source_path, str)
        assert isinstance(tagged_path, str)
        

        self.repo = git.Repo(tagged_path)

        self.tagged_documents = TaggedDocument.find(self.repo, tagged_extensions)
        self.source_documents = SourceDocument.find(source_path, source_extensions)

        self.language = language
    
    def process(self, dry_run=False, suffix=""):

        for doc in self.source_documents:
            assert isinstance(doc, SourceDocument)

            rendered_source = doc.render(self.tagged_documents, language=self.language)

            if dry_run:
                logging.info("Would write %s", doc.path)
            else:
                with open(doc.path + suffix, "w") as output_file:
                    output_file.write(rendered_source)
                logging.info("Writing %s", doc.path)



    
def main():
    options = optparse.OptionParser("%prog [options] asciidoc_dir sourcecode_dir")

    options.add_option("-l", "--lang", dest="language", default="swift")

    (opts, args) = options.parse_args()

    if len(args) != 2:
        options.print_usage()
        sys.exit(1)
    
    opts.source_dir = args[0]
    opts.code_dir = args[1]

    logging.getLogger().setLevel(logging.INFO)

    processor = Processor(opts.source_dir, opts.code_dir,source_extensions=["txt","asciidoc"], tagged_extensions=["swift","txt"], language=opts.language)

    logging.info("Found %i source files:", len(processor.source_documents))
    for doc in processor.source_documents:
        logging.info(" - %s", doc.path)
    
    logging.info("Found %i code files:", len(processor.tagged_documents))
    for doc in processor.tagged_documents:
        logging.info(" - %s", doc.path)
    
    processor.process()

if __name__ == '__main__':
    main()

@@ -1336,16 +1336,235 @@
 %22swift%22)
+%0A    options.add_option(%22-n%22, %22--dry-run%22, action=%22store_true%22, help=%22Don't actually modify any files%22)%0A    options.add_option(%22--suffix%22, default=%22%22, help=%22Append this to the file name of written files (default=none)%22)
 %0A%0A    (o
@@ -2286,16 +2286,56 @@
 process(
+dry_run=opts.dry_run, suffix=opts.suffix
 )%0A%0Aif __

Add --dry-run and --suffix options to processor.py