Index: DamEngine/trunk/src/DamEngine.sln =================================================================== diff -u -r1313 -r1314 --- DamEngine/trunk/src/DamEngine.sln (.../DamEngine.sln) (revision 1313) +++ DamEngine/trunk/src/DamEngine.sln (.../DamEngine.sln) (revision 1314) @@ -54,7 +54,7 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamEngine.Version", "Deltares.DamEngine.Version\Deltares.DamEngine.Version.csproj", "{4F235915-BF77-427C-9F8F-F2F05242C764}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamEngine.ConsoleRunner", "Deltares.DamEngine.ConsoleRunner\Deltares.DamEngine.ConsoleRunner.csproj", "{75D4440A-4E1F-4B15-8754-20C11EF3A222}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamEngine.ConsoleRun", "Deltares.DamEngine.ConsoleRun\Deltares.DamEngine.ConsoleRun.csproj", "{75D4440A-4E1F-4B15-8754-20C11EF3A222}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Index: DamEngine/trunk/lib/CommandLineParser/CommandLine.XML =================================================================== diff -u --- DamEngine/trunk/lib/CommandLineParser/CommandLine.XML (revision 0) +++ DamEngine/trunk/lib/CommandLineParser/CommandLine.XML (revision 1314) @@ -0,0 +1,868 @@ + + + + /home/giacomo/Projects/CommandLine/src/libcmdline/bin/Release/CommandLine + + + + + Provides base properties for creating an attribute, used to define rules for command line parsing. + + + + + Short name of this command line option. You can use only one character. + + + + + Long name of this command line option. This name is usually a single english word. + + + + + True if this command line option is required. + + + + + Gets or sets mapped property default value. + + + + + A short description of this command line option. Usually a sentence summary. + + + + + Indicates the instance method that must be invoked when it becomes necessary show your help screen. + The method signature is an instance method with no parameters and + return value. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class. + Allows you to define short and long option names. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Returns always false for this kind of option. + This behaviour can't be changed by design; if you try set + an will be thrown. + + + + + Models an option that can accept multiple values as separated arguments. + + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Models an option specification. + + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Gets or sets the option's mutually exclusive set. + + + + + Models an option that can accept multiple values. + Must be applied to a field compatible with an interface + of instances. + + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + + + + Initializes a new instance of the class. + + The short name of the option or null if not used. + The long name of the option or null if not used. + Values separator character. + + + + Gets or sets the values separator character. + + + + + Models a list of command line arguments that are not options. + Must be applied to a field compatible with an interface + of instances. + + + + + Initializes a new instance of the class. + + A type that implements . + Thrown if is null. + + + + Gets or sets the maximum element allow for the list managed by type. + If lesser than 0, no upper bound is fixed. + If equal to 0, no elements are allowed. + + + + + Models a bad parsed option. + + + + + The short name of the option + + Returns the short name of the option. + + + + The long name of the option + + Returns the long name of the option. + + + + Models a parsing error. + + + + + Gets or a the bad parsed option. + + + The bad option. + + + + + Gets or sets a value indicating whether this violates required. + + + true if violates required; otherwise, false. + + + + + Gets or sets a value indicating whether this violates format. + + + true if violates format; otherwise, false. + + + + + Gets or sets a value indicating whether this violates mutual exclusiveness. + + + true if violates mutual exclusiveness; otherwise, false. + + + + + Models a type that records the parser state afeter parsing. + + + + + Gets a list of parsing errors. + + + Parsing errors. + + + + + Defines a basic interface to parse command line arguments. + + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + This overload allows you to specify a derived instance for write text messages. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + Any instance derived from , + usually . Setting this argument to null, will disable help screen. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Provides the abstract base class for a strongly typed options target. Used when you need to get parsing errors. + + + + + This exception is thrown when a generic parsing error occurs. + + + + + Specifies a set of features to configure a behavior. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class, + setting the case comparison behavior. + + If set to true, parsing will be case sensitive. + + + + Initializes a new instance of the class, + setting the used for help method output. + + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Initializes a new instance of the class, + setting case comparison and help output options. + + If set to true, parsing will be case sensitive. + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Initializes a new instance of the class, + setting case comparison and mutually exclusive behaviors. + + If set to true, parsing will be case sensitive. + If set to true, enable mutually exclusive behavior. + + + + Initializes a new instance of the class, + setting case comparison, mutually exclusive behavior and help output option. + + If set to true, parsing will be case sensitive. + If set to true, enable mutually exclusive behavior. + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Initializes a new instance of the class, + setting case comparison, mutually exclusive behavior and help output option. + + If set to true, parsing will be case sensitive. + If set to true, enable mutually exclusive behavior. + If set to true, allow the parser to skip unknown argument, otherwise return a parse failure + Any instance derived from , + default . Setting this argument to null, will disable help screen. + + + + Gets or sets the case comparison behavior. + Default is set to true. + + + + + Gets or sets the mutually exclusive behavior. + Default is set to false. + + + + + Gets or sets the used for help method output. + Setting this property to null, will disable help screen. + + + + + Gets or sets a value indicating if the parser shall move on to the next argument and ignore the given argument if it + encounter an unknown arguments + + + true to allow parsing the arguments with differents class options that do not have all the arguments. + + + This allows fragmented version class parsing, useful for project with addon where addons also requires command line arguments but + when these are unknown by the main program at build time. + + + + + Provides methods to parse command line arguments. + Default implementation for . + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class, + configurable with a object. + + The object is used to configure + aspects and behaviors of the parser. + + + + Singleton instance created with basic defaults. + + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Parses a array of command line arguments, setting values in + parameter instance's public fields decorated with appropriate attributes. + This overload allows you to specify a derived instance for write text messages. + + A array of command line arguments. + An object's instance used to receive values. + Parsing rules are defined using derived types. + Any instance derived from , + usually . Setting this argument to null, will disable help screen. + True if parsing process succeed. + Thrown if is null. + Thrown if is null. + + + + Models an abstract sentence builder. + + + + + Gets a string containing word 'option'. + + + The word 'option'. + + + + + Gets a string containing the word 'and'. + + + The word 'and'. + + + + + Gets a string containing the sentence 'required option missing'. + + + The sentence 'required option missing'. + + + + + Gets a string containing the sentence 'violates format'. + + + The sentence 'violates format'. + + + + + Gets a string containing the sentence 'violates mutual exclusiveness'. + + + The sentence 'violates mutual exclusiveness'. + + + + + Gets a string containing the error heading text. + + + The error heading text. + + + + + Creates the built in sentence builder. + + + The built in sentence builder. + + + + + Models an english sentence builder, currently the default one. + + + + + Gets a string containing word 'option' in english. + + + The word 'option' in english. + + + + + Gets a string containing the word 'and' in english. + + + The word 'and' in english. + + + + + Gets a string containing the sentence 'required option missing' in english. + + + The sentence 'required option missing' in english. + + + + + Gets a string containing the sentence 'violates format' in english. + + + The sentence 'violates format' in english. + + + + + Gets a string containing the sentence 'violates mutual exclusiveness' in english. + + + The sentence 'violates mutual exclusiveness' in english. + + + + + Gets a string containing the error heading text in english. + + + The error heading text in english. + + + + + Models the copyright informations part of an help text. + You can assign it where you assign any instance. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class + specifying author and year. + + The company or person holding the copyright. + The year of coverage of copyright. + Thrown when parameter is null or empty string. + + + + Initializes a new instance of the class + specifying author and years. + + The company or person holding the copyright. + The years of coverage of copyright. + Thrown when parameter is null or empty string. + Thrown when parameter is not supplied. + + + + Initializes a new instance of the class + specifying symbol case, author and years. + + The case of the copyright symbol. + The company or person holding the copyright. + The years of coverage of copyright. + Thrown when parameter is null or empty string. + Thrown when parameter is not supplied. + + + + When overridden in a derived class, allows to specify a different copyright word. + + + + + Returns the copyright informations as a . + + The that contains the copyright informations. + + + + When overridden in a derived class, allows to specify a new algorithm to render copyright years + as a instance. + + A array of years. + A instance with copyright years. + + + + Converts the copyright informations to a . + + This instance. + The that contains the copyright informations. + + + + Models the heading informations part of an help text. + You can assign it where you assign any instance. + + + + + Initializes a new instance of the class + specifying program name. + + The name of the program. + Thrown when parameter is null or empty string. + + + + Initializes a new instance of the class + specifying program name and version. + + The name of the program. + The version of the program. + Thrown when parameter is null or empty string. + + + + Returns the heading informations as a . + + The that contains the heading informations. + + + + Writes out a string and a new line using the program name specified in the constructor + and parameter. + + The message to write. + The target derived type. + Thrown when parameter is null or empty string. + Thrown when parameter is null. + + + + Writes out a string and a new line using the program name specified in the constructor + and parameter to standard output stream. + + The message to write. + Thrown when parameter is null or empty string. + + + + Writes out a string and a new line using the program name specified in the constructor + and parameter to standard error stream. + + The message to write. + Thrown when parameter is null or empty string. + + + + Converts the heading informations to a . + + This instance. + The that contains the heading informations. + + + + Handle parsing errors delegate. + + + + + Provides data for the FormatOptionHelpText event. + + + + + Initializes a new instance of the class. + + Option to format. + + + + Gets the option to format. + + + + + Models an help text and collects related informations. + You can assign it in place of a instance. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class + specifying the sentence builder. + + + A instance. + + + + + Initializes a new instance of the class + specifying heading informations. + + A string with heading information or + an instance of . + Thrown when parameter is null or empty string. + + + + Initializes a new instance of the class + specifying the sentence builder and heading informations. + + + A instance. + + + A string with heading information or + an instance of . + + + + + Initializes a new instance of the class + specifying heading and copyright informations. + + A string with heading information or + an instance of . + A string with copyright information or + an instance of . + Thrown when one or more parameters are null or empty strings. + + + + Initializes a new instance of the class + specifying heading and copyright informations. + + A string with heading information or + an instance of . + A string with copyright information or + an instance of . + The instance that collected command line arguments parsed with class. + Thrown when one or more parameters are null or empty strings. + + + + Message type enumeration. + + + + + Parsing error due to a violation of the format of an option value. + + + + + Parsing error due to a violation of mandatory option. + + + + + Parsing error due to a violation of the mutual exclusiveness of two or more option. + + + + + Occurs when an option help text is formatted. + + + + + Sets the heading information string. + You can directly assign a instance. + + + + + Sets the copyright information string. + You can directly assign a instance. + + + + + Gets or sets the maximum width of the display. This determines word wrap when displaying the text. + + The maximum width of the display. + + + + Gets or sets the format of options for adding or removing dashes. + It modifies behavior of method. + + + + + Gets or sets whether to add an additional line after the description of the option. + + + + + Creates a new instance of the class using common defaults. + + + An instance of class. + + + The instance that collected command line arguments parsed with class. + + + + + Creates a new instance of the class using common defaults. + + + An instance of class. + + + The instance that collected command line arguments parsed with class. + + + A delegate used to customize the text block for reporting parsing errors. + + + + + Adds a text line after copyright and before options usage informations. + + A instance. + Thrown when parameter is null or empty string. + + + + Adds a text line at the bottom, after options usage informations. + + A instance. + Thrown when parameter is null or empty string. + + + + Adds a text block with options usage informations. + + The instance that collected command line arguments parsed with class. + Thrown when parameter is null. + + + + Adds a text block with options usage informations. + + The instance that collected command line arguments parsed with the class. + The word to use when the option is required. + Thrown when parameter is null. + Thrown when parameter is null or empty string. + + + + Adds a text block with options usage informations. + + The instance that collected command line arguments parsed with the class. + The word to use when the option is required. + The maximum length of the help documentation. + Thrown when parameter is null. + Thrown when parameter is null or empty string. + + + + Builds a string that contains a parsing error message. + + + An options target instance that collected command line arguments parsed with the class. + + + The that contains the parsing error message. + + + + + Returns the help informations as a . + + The that contains the help informations. + + + + Converts the help informations to a . + + This instance. + The that contains the help informations. + + + Index: DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/App.config =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/App.config (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/App.config (revision 1314) @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Deltares.DamEngine.ConsoleRun.csproj =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Deltares.DamEngine.ConsoleRun.csproj (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Deltares.DamEngine.ConsoleRun.csproj (revision 1314) @@ -0,0 +1,54 @@ + + + + + Debug + x86 + {75D4440A-4E1F-4B15-8754-20C11EF3A222} + Exe + Properties + Deltares.DamEngine.ConsoleRun + DamConsoleRun + v4.5 + 512 + + + + + ..\..\lib\CommandLineParser\CommandLine.dll + + + + + + + + + + + + + + + + + + Copying.AGPL.licenseheader + + + + + + {750464A3-CBFA-429F-920E-B430867F1120} + Deltares.DamEngine.Interface + + + + + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Properties/AssemblyInfo.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Properties/AssemblyInfo.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Properties/AssemblyInfo.cs (revision 1314) @@ -0,0 +1,29 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Deltares.DamEngine.ConsoleRunner")] +[assembly: AssemblyProduct("Deltares.DamEngine.ConsoleRunner")] +[assembly: ComVisible(false)] +[assembly: Guid("75d4440a-4e1f-4b15-8754-20c11ef3a222")] + Index: DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Program.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Program.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/Program.cs (revision 1314) @@ -0,0 +1,48 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using CommandLine; +using Deltares.DamEngine.Interface; + +namespace Deltares.DamEngine.ConsoleRun +{ + internal class Program + { + static void Main(string[] args) + { + var commandLineArguments = new CommandOptions(); + ICommandLineParser parser = new CommandLineParser(); + bool success = parser.ParseArguments(args, commandLineArguments); + if (success) + { + string inputXml =""; + var damEnginInterface = new EngineInterface(inputXml); + } + else + { + Console.WriteLine(); + Console.WriteLine(commandLineArguments.GetUsage()); + } + + } + } +} Index: DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/CommandOptions.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/CommandOptions.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.ConsoleRun/CommandOptions.cs (revision 1314) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using CommandLine; +using CommandLine.Text; + +namespace Deltares.DamEngine.ConsoleRun +{ + internal class CommandOptions : CommandLineOptionsBase + { + public const string DefaultInputFileName = "InputFile.xml"; + public const string DefaultOutputFileName = "OutputFile.xml"; + + [Option("i", "input", Required = true, DefaultValue = DefaultInputFileName, HelpText = "Name and path of the input file.")] + public string InputFileName { get; set; } + + [Option("o", "output", Required = false, DefaultValue = DefaultOutputFileName, HelpText = "Name and path of the output file.")] + public string OutputFileName { get; set; } + +// readonly AssemblyInfoHelper assemblyInfoHelper = new AssemblyInfoHelper(typeof(Program)); +// private AssemblyInfoHelper ThisAssembly +// { +// get +// { +// return assemblyInfoHelper; +// } +// } + + [HelpOption] + public string GetUsage() + { + var help = new HelpText + { + Heading = "Dam Console Runner", + Copyright = "Copyright (c) 2018 Deltares", + AdditionalNewLineAfterOption = true, + AddDashesToOption = true + }; + + this.HandleParsingErrorsInHelp(help); + + help.AddPreOptionsLine("Usage: DamConsoleRunner[.exe] -i InputFile [ -o OutputFile]"); + help.AddOptions(this); + + return help; + } + + void HandleParsingErrorsInHelp(HelpText help) + { + if (this.LastPostParsingState.Errors.Count > 0) + { + var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces + if (!string.IsNullOrEmpty(errors)) + { + help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):")); + help.AddPreOptionsLine(errors); + } + } + } + + } +} Index: DamEngine/trunk/lib/CommandLineParser/CommandLine.dll =================================================================== diff -u Binary files differ Index: DamEngine/trunk/lib/CommandLineParser/readme.txt =================================================================== diff -u --- DamEngine/trunk/lib/CommandLineParser/readme.txt (revision 0) +++ DamEngine/trunk/lib/CommandLineParser/readme.txt (revision 1314) @@ -0,0 +1,48 @@ +Command Line Parser Library 1.9.3.19 Beta +----------------------------------------- +Giacomo Stelluti Scala +(gsscoder@gmail.com) + +Codeplex: http://commandline.codeplex.com/ +GitHub (Latest Sources, Updated Docs): https://github.com/gsscoder/commandline + +Upgrading from 1.8.* versions: +------------------------------ +The major API change is that all attributes that inherits from BaseOptionAttribute now +apply only to properties. Fields are no longer supported. + +Old Code: +--------- +class Options { + [Option("o", "my-option", HelpText="This is an option!")] + public int MyOption = 10; +} + +New Code: +--------- +class Options { + [Option("o", "my-option", DefaultValue=10, HelpText="This is an option!")] + public int MyOption { get; set; } +} + +As you can see I've added the new DefaultValue property to help you initialize properties. + +Shortcut for Help Screen +------------------------ +[HelpOption] +public string GetUsage() +{ + return HelpText.AutoBuild(this, + (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current)); +} + +Note: +----- +If you don't use mutually exclusive options, now there's a singleton built for common uses: + +if (CommandLineParser.Default.ParseArguments(args, options)) { + // consume values here +} + + +Have fun! \ No newline at end of file Fisheye: Tag 1314 refers to a dead (removed) revision in file `DamEngine/trunk/src/Deltares.DamEngine.ConsoleRunner/App.config'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1314 refers to a dead (removed) revision in file `DamEngine/trunk/src/Deltares.DamEngine.ConsoleRunner/Properties/AssemblyInfo.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1314 refers to a dead (removed) revision in file `DamEngine/trunk/src/Deltares.DamEngine.ConsoleRunner/Deltares.DamEngine.ConsoleRunner.csproj'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1314 refers to a dead (removed) revision in file `DamEngine/trunk/src/Deltares.DamEngine.ConsoleRunner/Program.cs'. Fisheye: No comparison available. Pass `N' to diff?