Changeset 750


Ignore:
Timestamp:
Mar 27, 2013, 5:13:41 PM (12 years ago)
Author:
s10k
Message:
  • now also return errors when the arguments are incorrect
  • added parameter to display xmlTools errors

0.8d

Location:
xmlTools/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • xmlTools/trunk/posUpdate/ParametersParser.cs

    r742 r750  
    1212    class ParametersParser
    1313    {
    14         private static string globalFileName="";
    15         private static string globalElement="";
    16         private static string globalParentElement="";
     14        private static string globalFileName = "";
     15        private static string globalElement = "";
     16        private static string globalParentElement = "";
    1717        private static bool globalNoBackups = false;
    1818
     
    149149        }
    150150
     151        [Verb]
     152        public static void showErrTypes()
     153        {
     154            Array values = Enum.GetValues(typeof(Program.appErrors));
     155
     156            foreach (Program.appErrors val in values)
     157            {
     158                Console.WriteLine(Enum.GetName(typeof(Program.appErrors),val) + " : " + (int)val);
     159            }
     160        }
     161
    151162        // Global Parameters
    152163        [Global(Description = "Filename to apply the operations (with patchFile specifies the patch filename). Wildcards accepted for multiple files. No filename = search all .xml files in current path.")]
  • xmlTools/trunk/posUpdate/Program.cs

    r746 r750  
    1111    class Program
    1212    {
    13         public static readonly string toolsVersion = "0.8c";
    14         private static appErrors lastError;
     13        public static readonly string toolsVersion = "0.8d";
     14        private static appErrors lastError = appErrors.NO_ERROR;
    1515
    1616        public enum appErrors
    1717        {
    1818            // 1-19 Errors with input parameters
     19            NO_ERROR = 0,
    1920            ERROR_PARAMS = 1,
    2021            FILE_NOT_FOUND = 2,
    21             ELEMENT_NOT_SPECIFIED=3,
    22             ELEMENT_NOT_FOUND=4,
     22            ELEMENT_NOT_SPECIFIED = 3,
     23            ELEMENT_NOT_FOUND = 4,
    2324            // 20-199 General application errors
    24             BACKUPS_ALREADY_EXISTS=20,
     25            BACKUPS_ALREADY_EXISTS = 20,
    2526            NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21,
    26             INVALID_POSITIONS_RANGE=22,
     27            INVALID_POSITIONS_RANGE = 22,
    2728            // 200-299 Patch operations errors
    2829            PATCH_ADDTO_PROCESS_ERROR = 200,
    2930            PATCH_REMOVE_PROCESS_ERROR = 201,
    30             PATCH_COMMAND_PROCESS_ERROR=202,
    31             PATCH_ELEMENT_NOT_FOUND=203,
    32             PATCH_ADDTO_ERROR_PARSING_XML=204,
    33             PATCH_COMMAND_NOT_FOUND=205
     31            PATCH_COMMAND_PROCESS_ERROR = 202,
     32            PATCH_ELEMENT_NOT_FOUND = 203,
     33            PATCH_ADDTO_ERROR_PARSING_XML = 204,
     34            PATCH_COMMAND_NOT_FOUND = 205
    3435        }
    3536
    36         public static void printAppError(appErrors error, string description, bool exitApp=false){
    37             Console.Error.WriteLine("Error Code: "+(int)error);
     37        public static void printAppError(appErrors error, string description, bool exitApp = false)
     38        {
     39            Console.Error.WriteLine("Error Code: " + (int)error);
    3840            Console.Error.WriteLine(description);
    3941
     
    5153            {
    5254                //We use a command parse library due to its advantages
    53                 CLAP.Parser.RunConsole<ParametersParser>(args);
     55                appErrors result = (appErrors)CLAP.Parser.RunConsole<ParametersParser>(args);
     56                if (result != appErrors.NO_ERROR)
     57                {
     58                    lastError = result;
     59                }
    5460                return (int)lastError;
    5561            }
  • xmlTools/trunk/posUpdate/xmlTools.csproj.user

    r745 r750  
    22<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    33  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    4     <StartArguments>patchfile -filename:TRAM-knockdown.oni-patch</StartArguments>
     4    <StartArguments>versions</StartArguments>
    55  </PropertyGroup>
    66  <PropertyGroup>
     
    1515  </PropertyGroup>
    1616  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    17     <StartArguments>replaceall -element:FirstLevel -value:0 -nobackups -filename:"C:\Users\home\Documents\Visual Studio 2012\Projects\posUpdate\posUpdate\bin\Debug\%2a.xml"</StartArguments>
     17    <StartArguments>replacealsl -element:FirstLevel -value:0 -nobackups -filename:"C:\Users\home\Documents\Visual Studio 2012\Projects\posUpdate\posUpdate\bin\Debug\%2a.xml"</StartArguments>
    1818  </PropertyGroup>
    1919</Project>
Note: See TracChangeset for help on using the changeset viewer.