Exemplo n.º 1
0
        public void SvgForHamburgersTest()
        {
            string path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "cogsburger");

            string subdir     = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string outputPath = Path.Combine(Path.GetTempPath(), subdir);

            var directoryReader = new CogsDirectoryReader();
            var cogsDtoModel    = directoryReader.Load(path);

            var modelBuilder = new CogsModelBuilder();
            var cogsModel    = modelBuilder.Build(cogsDtoModel);

            var choices = new string[3] {
                "all", "type", "single"
            };

            for (int i = 0; i < 3; i++)
            {
                var publisher = new DotSchemaPublisher
                {
                    TargetDirectory = outputPath,
                    Output          = choices[i],
                    Format          = "svg"
                };
                publisher.Publish(cogsModel);
            }
        }
Exemplo n.º 2
0
        public void UmlForHamburgersTest()
        {
            string path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "cogsburger");

            string subdir     = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string outputPath = Path.Combine(Path.GetTempPath(), subdir);

            var directoryReader = new CogsDirectoryReader();
            var cogsDtoModel    = directoryReader.Load(path);

            var modelBuilder = new CogsModelBuilder();
            var cogsModel    = modelBuilder.Build(cogsDtoModel);

            // test both normative and not normative outputs
            var publisher = new UmlSchemaPublisher
            {
                TargetDirectory = outputPath,
                Normative       = false
            };

            publisher.Publish(cogsModel);
            // test with normative since 2.5 does not have a xsd schema yet
            Validate(Path.Combine(outputPath, "uml.xmi.xml"));

            publisher = new UmlSchemaPublisher
            {
                TargetDirectory = outputPath,
                Normative       = true
            };
            publisher.Publish(cogsModel);
            // not working yet
            Validate(Path.Combine(outputPath, "uml.xmi.xml"));
        }
Exemplo n.º 3
0
        public async System.Threading.Tasks.Task asyncJsonSchemaTestAsync()
        {
            string path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "cogsburger");

            string subdir     = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string outputPath = Path.Combine(Path.GetTempPath(), subdir);

            var directoryReader = new CogsDirectoryReader();
            var cogsDtoModel    = directoryReader.Load(path);

            var modelBuilder = new CogsModelBuilder();
            var cogsModel    = modelBuilder.Build(cogsDtoModel);

            var jsonPublisher = new JsonPublisher();

            jsonPublisher.TargetDirectory = outputPath;
            jsonPublisher.Publish(cogsModel);

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                MetadataPropertyHandling = MetadataPropertyHandling.Ignore
            };
            var schemaData = File.ReadAllText(Path.Combine(outputPath, "jsonSchema" + ".json"));
            var schema     = await JsonSchema4.FromJsonAsync(schemaData);

            string[] tests = new string[]
            {
                "testing1_reference_reusable.json",
                "testing2_reference_Object.json",
                "test3_SimpleType.json",
                "test4_invalid_json.json",
                "ToDo.json",
                "testing5_more.json",
                "jsonOut.json"
            };
            foreach (var test in tests)
            {
                using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Cogs.Tests." + test))
                {
                    StringBuilder lines = new StringBuilder();
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            lines.Append(line);
                        }
                    }
                    if (!test.Contains("invalid"))
                    {
                        Assert.Empty(schema.Validate(lines.ToString()));
                    }
                    else
                    {
                        Assert.NotEmpty(schema.Validate(lines.ToString()));
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void CsForHamburgersTest()
        {
            string path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "cogsburger");

            string subdir     = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string outputPath = Path.Combine(Path.GetTempPath(), subdir);

            var directoryReader = new CogsDirectoryReader();
            var cogsDtoModel    = directoryReader.Load(path);

            var modelBuilder = new CogsModelBuilder();
            var cogsModel    = modelBuilder.Build(cogsDtoModel);

            var publisher = new CsSchemaPublisher
            {
                TargetDirectory = outputPath
            };

            publisher.Publish(cogsModel);

            // get the dotnet filepath
            string dotLoc = null;

            if (File.Exists("dotnet.exe"))
            {
                dotLoc = Path.GetFullPath("dotnet.exe");
            }
            else
            {
                var values = Environment.GetEnvironmentVariable("PATH");
                foreach (var exe in values.Split(Path.PathSeparator))
                {
                    var fullPath = Path.Combine(exe, "dotnet.exe");
                    if (File.Exists(fullPath))
                    {
                        dotLoc = fullPath;
                    }
                }
            }
            if (dotLoc == null)
            {
                throw new InvalidOperationException();
            }

            Build("cogsburger", outputPath, dotLoc);
        }
Exemplo n.º 5
0
        public void LoadHamburgerModelTest()
        {
            string path            = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "cogsburger");
            var    directoryReader = new CogsDirectoryReader();
            var    cogsDtoModel    = directoryReader.Load(path);

            var modelBuilder = new CogsModelBuilder();
            var cogsModel    = modelBuilder.Build(cogsDtoModel);

            // Verify we read all the item types.
            Assert.Equal(10, cogsModel.ItemTypes.Count);
            Assert.Equal(3, cogsModel.ReusableDataTypes.Count);

            // Verify we read all the inheritance correctly.
            var rollType = cogsModel.ItemTypes.First(x => x.Name == "Roll");

            Assert.Equal("Breading", rollType.ExtendsTypeName);

            // Verify we read Topics correctly.
            Assert.Single(cogsModel.TopicIndices);

            // TODO Verify we read properties correctly.
        }
Exemplo n.º 6
0
        public void SphinxForHamburgersTest()
        {
            string path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "cogsburger");

            string subdir     = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string outputPath = Path.Combine(Path.GetTempPath(), subdir);

            var directoryReader = new CogsDirectoryReader();
            var cogsDtoModel    = directoryReader.Load(path);

            var modelBuilder = new CogsModelBuilder();
            var cogsModel    = modelBuilder.Build(cogsDtoModel);

            var sphinxPublisher = new SphinxPublisher
            {
                TargetDirectory = outputPath
            };

            sphinxPublisher.Publish(cogsModel);


            // TODO Inspect the sphinx directory to make sure it has some things we expect.
            // For now we are just making sure there are no errors while running.
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            System.Console.WriteLine(cogsLogo);

            var app = new CommandLineApplication
            {
                Name = "Cogs"
            };

            app.HelpOption("-?|-h|--help");


            app.Command("validate", (command) =>
            {
                command.Description = "Validate a on disk COGS data model directory";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");

                command.OnExecute(() =>
                {
                    var location = locationArgument.Value ?? Environment.CurrentDirectory;

                    // read cogs directory and validate the contents
                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);
                    HandleErrors(directoryReader.Errors);
                    HandleErrors(DtoValidation.Validate(cogsDtoModel));

                    // this could find gaps in the validation, but idealy return nothing
                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);
                    HandleErrors(modelBuilder.Errors);

                    return(0);
                });
            });

            app.Command("publish-xsd", (command) =>
            {
                command.Description = "Publish an XML schema from a COGS data model";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the xsd schema is generated.");

                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);

                var namespaceUri = command.Option("-n|--namespace",
                                                  "URI of the target XML namespace",
                                                  CommandOptionType.SingleValue);

                var namespaceUriPrefix = command.Option("-p|--namespacePrefix",
                                                        "Namespace prefix to use for the target XML namespace",
                                                        CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();

                    // read cogs directory and validate the contents
                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);
                    HandleErrors(directoryReader.Errors);
                    HandleErrors(DtoValidation.Validate(cogsDtoModel));

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);
                    HandleErrors(modelBuilder.Errors);

                    var targetNamespace = namespaceUri.Value() ?? cogsModel.Settings.NamespaceUrl;
                    var prefix          = namespaceUriPrefix.Value() ?? cogsModel.Settings.NamespacePrefix;
                    try
                    {
                        XmlConvert.VerifyName(prefix);
                    }
                    catch (XmlException xmlEx)
                    {
                        CogsError xmlPrefixError = new CogsError(ErrorLevel.Error, "Invalid xml prefix string", xmlEx);
                        HandleErrors(new List <CogsError>()
                        {
                            xmlPrefixError
                        });
                    }

                    XmlSchemaPublisher publisher = new XmlSchemaPublisher
                    {
                        CogsLocation          = location,
                        TargetDirectory       = target,
                        Overwrite             = overwrite,
                        TargetNamespace       = targetNamespace,
                        TargetNamespacePrefix = prefix
                    };

                    publisher.Publish(cogsModel);
                    HandleErrors(publisher.Errors);


                    return(0);
                });
            });


            app.Command("publish-uml", (command) =>
            {
                command.Description = "Publish an UML schema from a COGS data model";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the UML schema is generated.");

                var dotOption = command.Option("-l|--location", "Directory where the dot.exe file is located. " +
                                               "Only used if not using normative and not necessary for windows.", CommandOptionType.SingleValue);
                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);
                var normativeOption = command.Option("-n|--normative",
                                                     "Output a normative xmi file (2.4.2) instead of xmi 2.5.1. Note: cannot contain a graph element",
                                                     CommandOptionType.NoValue);

                command.OnExecute(() =>
                {
                    var dot        = dotOption.Value() ?? null;
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();
                    bool normative = normativeOption.HasValue();

                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    UmlSchemaPublisher publisher = new UmlSchemaPublisher
                    {
                        DotLocation     = dot,
                        TargetDirectory = target,
                        Overwrite       = overwrite,
                        Normative       = normative
                    };
                    publisher.Publish(cogsModel);


                    return(0);
                });
            });

            app.Command("publish-dot", (command) =>
            {
                command.Description = "Publish a dot schema from a COGS data model";
                command.HelpOption("-?|-h|--help");


                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the dot schema is generated.");

                var dotOption = command.Option("-l|--location", "Directory where the dot.exe file is located. " +
                                               "Only used if not using normative and not necessary for windows.", CommandOptionType.SingleValue);
                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);
                var outputFormat = command.Option("-f|--format", "Specifies format for output file. Defaults to svg", CommandOptionType.SingleValue);
                var outputAll    = command.Option("-a|--all",
                                                  "generate one graph containing all objects. Cannot be used with -s",
                                                  CommandOptionType.NoValue);
                var outputSingle = command.Option("-s|--single",
                                                  "generate a graph for every single item (incoming links and outgoing links). Cannot be used with -a",
                                                  CommandOptionType.NoValue);
                var inheritanceArgument = command.Option("-i|--inheritance",
                                                         "allow inheritance in the graph(s)", CommandOptionType.NoValue);
                var reusableArgument = command.Option("-c|--composite", "show composite types inside item types", CommandOptionType.NoValue);

                command.OnExecute(() =>
                {
                    var dot        = dotOption.Value() ?? null;
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();
                    string format  = outputFormat.Value() ?? "svg";
                    bool all       = outputAll.HasValue();
                    bool single    = outputSingle.HasValue();
                    if (all && single)
                    {
                        throw new ArgumentException();
                    }
                    string output = "topic";
                    if (all)
                    {
                        output = "all";
                    }
                    else if (single)
                    {
                        output = "single";
                    }
                    bool reusables   = reusableArgument.HasValue();
                    bool inheritance = inheritanceArgument.HasValue();

                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    DotSchemaPublisher publisher = new DotSchemaPublisher
                    {
                        DotLocation     = dot,
                        TargetDirectory = target,
                        Overwrite       = overwrite,
                        Format          = format,
                        Output          = output,
                        Inheritance     = inheritance,
                        ShowReusables   = reusables
                    };
                    publisher.Publish(cogsModel);
                    HandleErrors(publisher.Errors);
                    return(0);
                });
            });

            app.Command("publish-cs", (command) =>
            {
                command.Description = "Publish a c# class structure from a COGS data model";
                command.HelpOption("-?|-h|--help");


                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the c# schema is generated.");

                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);
                var namespaceUri = command.Option("-n|--namespace",
                                                  "URI of the target XML namespace",
                                                  CommandOptionType.SingleValue);

                var namespaceUriPrefix = command.Option("-p|--prefix",
                                                        "Namespace prefix to use for the target XML namespace",
                                                        CommandOptionType.SingleValue);
                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();

                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    var targetNamespace = namespaceUri.Value() ?? cogsModel.Settings.NamespaceUrl;
                    var prefix          = namespaceUriPrefix.Value() ?? cogsModel.Settings.NamespacePrefix;
                    try
                    {
                        XmlConvert.VerifyName(prefix);
                    }
                    catch (XmlException xmlEx)
                    {
                        CogsError xmlPrefixError = new CogsError(ErrorLevel.Error, "Invalid xml prefix string", xmlEx);
                        HandleErrors(new List <CogsError>()
                        {
                            xmlPrefixError
                        });
                    }

                    CsSchemaPublisher publisher = new CsSchemaPublisher
                    {
                        TargetDirectory       = target,
                        TargetNamespace       = targetNamespace,
                        TargetNamespacePrefix = prefix,
                        Overwrite             = overwrite
                    };
                    publisher.Publish(cogsModel);

                    return(0);
                });
            });


            app.Command("publish-sphinx", (command) =>
            {
                command.Description = "Publish a Sphinx documentation website from a COGS data model";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the sphinx documentation is generated.");

                var dotOption = command.Option("-l|--location", "Directory where the dot.exe file is located. " +
                                               "Only used if not using normative and not necessary for windows.", CommandOptionType.SingleValue);
                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);



                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    var dot        = dotOption.Value() ?? null;
                    bool overwrite = overwriteOption.HasValue();

                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    SphinxPublisher publisher = new SphinxPublisher
                    {
                        TargetDirectory = target,
                        Overwrite       = overwrite,
                        DotLocation     = dot
                    };

                    publisher.Publish(cogsModel);
                    return(0);
                });
            });

            app.Command("publish-json", (command) =>
            {
                command.Description = "Publish a JSON schema from a COGS data model";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the json schema is generated.");

                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);
                var additionalprop = command.Option("-a|--allowAdditionalProperties",
                                                    "Allow additional Properties to be added when enabled", CommandOptionType.NoValue);



                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();
                    bool addprop   = additionalprop.HasValue();


                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    JsonPublisher publisher = new JsonPublisher
                    {
                        CogsLocation    = location,
                        TargetDirectory = target,
                        Overwrite       = overwrite,
                        AdditionalProp  = addprop
                    };

                    publisher.Publish(cogsModel);


                    return(0);
                });
            });

            app.Command("publish-GraphQL", (command) =>
            {
                command.Description = "Publish a GraphQL schema from a COGS data model";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the json schema is generated.");

                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);



                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();


                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    GraphQLPublisher publisher = new GraphQLPublisher
                    {
                        CogsLocation    = location,
                        TargetDirectory = target,
                        Overwrite       = overwrite
                    };

                    publisher.Publish(cogsModel);

                    return(0);
                });
            });

            app.Command("publish-owl", (command) =>
            {
                command.Description = "Publish an OWL/RDF schema from a COGS data model";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the owl schema is generated.");

                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);

                var namespaceUri = command.Option("-n|--namespace",
                                                  "URI of the target Owl namespace",
                                                  CommandOptionType.SingleValue);

                var namespaceUriPrefix = command.Option("-p|--namespacePrefix",
                                                        "Namespace prefix to use for the target Owl namespace",
                                                        CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();

                    // read cogs directory and validate the contents
                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);
                    HandleErrors(directoryReader.Errors);
                    HandleErrors(DtoValidation.Validate(cogsDtoModel));

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);
                    HandleErrors(modelBuilder.Errors);

                    var targetNamespace = namespaceUri.Value() ?? cogsModel.Settings.NamespaceUrl;
                    var prefix          = namespaceUriPrefix.Value() ?? cogsModel.Settings.NamespacePrefix;

                    try
                    {
                        XmlConvert.VerifyName(prefix);
                    }
                    catch (XmlException xmlEx)
                    {
                        CogsError xmlPrefixError = new CogsError(ErrorLevel.Error, "Invalid xml prefix string", xmlEx);
                        HandleErrors(new List <CogsError>()
                        {
                            xmlPrefixError
                        });
                    }

                    OwlPublisher publisher = new OwlPublisher
                    {
                        CogsLocation          = location,
                        TargetDirectory       = target,
                        Overwrite             = overwrite,
                        TargetNamespace       = targetNamespace,
                        TargetNamespacePrefix = prefix
                    };

                    publisher.Publish(cogsModel);
                    //HandleErrors(publisher.Errors);


                    return(0);
                });
            });

            app.Command("cogs-new", (command) =>
            {
                command.Description = "create a model skeleton";
                command.HelpOption("-?|-h|--help");

                var locationArgument = command.Argument("[cogsLocation]", "Directory where the COGS datamodel is located.");
                var targetArgument   = command.Argument("[targetLocation]", "Directory where the model skelton is generated.");

                var overwriteOption = command.Option("-o|--overwrite",
                                                     "If the target directory exists, delete and overwrite the location",
                                                     CommandOptionType.NoValue);



                command.OnExecute(() =>
                {
                    var location   = locationArgument.Value ?? Environment.CurrentDirectory;
                    var target     = targetArgument.Value ?? Path.Combine(Directory.GetCurrentDirectory(), "out");
                    bool overwrite = overwriteOption.HasValue();

                    var directoryReader = new CogsDirectoryReader();
                    var cogsDtoModel    = directoryReader.Load(location);

                    var modelBuilder = new CogsModelBuilder();
                    var cogsModel    = modelBuilder.Build(cogsDtoModel);

                    ModelInitializer cogsmodel = new ModelInitializer
                    {
                        Dir       = location,
                        Overwrite = overwrite
                    };

                    cogsmodel.Create();


                    return(0);
                });
            });

            app.OnExecute(() =>
            {
                System.Console.WriteLine("Cogs");
                return(0);
            });


            var result = app.Execute(args);

            Environment.Exit(result);
        }