/// <summary> /// Configure command line options. /// </summary> /// <param name="arguements">Arguments from the command line.</param> /// <returns>The command line options.</returns> private CommandLineSettings ConfigureCommandLineOptions(IEnumerable <string> arguements) { var settings = new CommandLineSettings(); _options = new OptionSet { { "n=|namespace=", "Namespace contaning all of the generated classes", ns => settings.Config.Namespace = ns }, { "s=|schema=", "File path to the schema file", s => settings.Config.JsonSchemaFileLocation = s }, { "o=|output=", "Directory to save files", fn => settings.Config.OutputDirectory = fn }, { "v|verbose", "Print out files in console without generating", v => settings.Config.Verbose = !string.IsNullOrWhiteSpace(v) }, { "a=|attribute=", "Attribute type (1 - Default DataAnnotations, 2 - JSON.net compatible attributes", fn => settings.Config.AttributeType = (AttributeType)Enum.Parse(typeof(AttributeType), fn) }, { "?|help", "Show this help message", h => settings.ShowHelp = !string.IsNullOrWhiteSpace(h) }, { "nd|nonamespacedirectories", "Don't generate namespace directories", nd => settings.Config.GenerateNamespaceDirectories = string.IsNullOrWhiteSpace(nd) } }; _options.Parse(arguements); return(settings); }
/// <summary> /// Configure command line options. /// </summary> /// <param name="arguements">Arguments from the command line.</param> /// <returns>The command line options.</returns> private CommandLineSettings ConfigureCommandLineOptions(IEnumerable<string> arguements) { var settings = new CommandLineSettings(); _options = new OptionSet { {"n=|namespace=", "Namespace contaning all of the generated classes", ns => settings.Config.Namespace = ns}, {"s=|schema=", "File path to the schema file", s => settings.Config.JsonSchemaFileLocation = s}, {"o=|output=", "Directory to save files", fn => settings.Config.OutputDirectory = fn}, { "v|verbose", "Print out files in console without generating", v => settings.Config.Verbose = !string.IsNullOrWhiteSpace(v) }, { "a=|attribute=", "Attribute type (1 - Default DataAnnotations, 2 - JSON.net compatible attributes", fn => settings.Config.AttributeType = (AttributeType) Enum.Parse(typeof(AttributeType), fn) }, {"?|help", "Show this help message", h => settings.ShowHelp = !string.IsNullOrWhiteSpace(h)}, {"nd|nonamespacedirectories", "Don't generate namespace directories", nd => settings.Config.GenerateNamespaceDirectories = string.IsNullOrWhiteSpace(nd) } }; _options.Parse(arguements); return settings; }
/// <summary> /// Constructor taking in command line arguments. /// </summary> /// <param name="args">Command line arguments.</param> public JsonSchemaToPocoCLExecutor(IEnumerable <string> args) { _settings = ConfigureCommandLineOptions(args); _controller = new JsonSchemaToPoco(_settings.Config); }
/// <summary> /// Constructor taking in command line arguments. /// </summary> /// <param name="args">Command line arguments.</param> public JsonSchemaToPocoCLExecutor(IEnumerable<string> args) { _settings = ConfigureCommandLineOptions(args); _controller = new JsonSchemaToPoco(_settings.Config); }