public static void GetOpt <T1, T2, T3, T4>(ref string[] command, OptionDescriptor <T1> d1, OptionDescriptor <T2> d2, OptionDescriptor <T3> d3, OptionDescriptor <T4> d4) { GetOpt(ref command, d1); GetOpt(ref command, d2); GetOpt(ref command, d3); GetOpt(ref command, d4); }
public static void GetOpt <T1, T2, T3, T4, T5, T6>(ref string[] command, OptionDescriptor <T1> d1, OptionDescriptor <T2> d2, OptionDescriptor <T3> d3, OptionDescriptor <T4> d4, OptionDescriptor <T5> d5, OptionDescriptor <T6> d6) { GetOpt(ref command, d1); GetOpt(ref command, d2); GetOpt(ref command, d3); GetOpt(ref command, d4); GetOpt(ref command, d5); GetOpt(ref command, d6); }
public static void GetOpt(ref string[] command, OptionDescriptor <bool> descriptor) { int idx = Index(command, descriptor); descriptor.value = false; if (idx != -1) { descriptor.value = true; descriptor.set = true; List <string> list = command.ToList(); list.RemoveAt(idx); command = list.ToArray(); } }
public static void GetOpt(ref string[] command, OptionDescriptor <ulong> descriptor) { int idx = Index(command, descriptor); if (idx != -1 && idx < command.Length - 1) { descriptor.set = ulong.TryParse(command[idx + 1], out descriptor.value); if (descriptor.set) { List <string> list = command.ToList(); list.RemoveAt(idx); list.RemoveAt(idx); command = list.ToArray(); } } }
private static int Index <T>(string[] command, OptionDescriptor <T> descriptor) { for (int i = 0, length = command.Length; i < length; ++i) { if (command[i].StartsWith("--", StringComparison.Ordinal)) { if (command[i].Substring(2) == descriptor.LongOption) { return(i); } } else if (command[i].StartsWith("-", StringComparison.Ordinal)) { if (command[i].Substring(1) == descriptor.ShortOption) { return(i); } } } return(-1); }
public static void GetOpt <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ref string[] command, OptionDescriptor <T1> d1, OptionDescriptor <T2> d2, OptionDescriptor <T3> d3, OptionDescriptor <T4> d4, OptionDescriptor <T5> d5, OptionDescriptor <T6> d6, OptionDescriptor <T7> d7, OptionDescriptor <T8> d8, OptionDescriptor <T9> d9, OptionDescriptor <T10> d10) { GetOpt(ref command, d1); GetOpt(ref command, d2); GetOpt(ref command, d3); GetOpt(ref command, d4); GetOpt(ref command, d5); GetOpt(ref command, d6); GetOpt(ref command, d7); GetOpt(ref command, d8); GetOpt(ref command, d9); GetOpt(ref command, d10); }
public static void GetOpt <T1, T2>(ref string[] command, OptionDescriptor <T1> d1, OptionDescriptor <T2> d2) { GetOpt(ref command, d1); GetOpt(ref command, d2); }
public static void GetOpt <T>(ref string[] command, OptionDescriptor <T> descriptor) { //fix: GetOpt will wipe out all quotes with CmdSplit. make them \" first. //for ( int i = 0; i < command.Length; ++i ) //{ // command[i] = command[i].Replace( "\"", "\\\"" ); //} //command = CommandLineTools.CmdSplit(string.Join(" ", command)); if (typeof(T) == typeof(bool)) { GetOpt(ref command, descriptor as OptionDescriptor <bool>); return; } if (typeof(T) == typeof(byte)) { GetOpt(ref command, descriptor as OptionDescriptor <byte>); return; } if (typeof(T) == typeof(char)) { GetOpt(ref command, descriptor as OptionDescriptor <char>); return; } if (typeof(T) == typeof(short)) { GetOpt(ref command, descriptor as OptionDescriptor <short>); return; } if (typeof(T) == typeof(int)) { GetOpt(ref command, descriptor as OptionDescriptor <int>); return; } if (typeof(T) == typeof(long)) { GetOpt(ref command, descriptor as OptionDescriptor <long>); return; } if (typeof(T) == typeof(float)) { GetOpt(ref command, descriptor as OptionDescriptor <float>); return; } if (typeof(T) == typeof(double)) { GetOpt(ref command, descriptor as OptionDescriptor <double>); return; } if (typeof(T) == typeof(string)) { GetOpt(ref command, descriptor as OptionDescriptor <string>); return; } if (typeof(T) == typeof(sbyte)) { GetOpt(ref command, descriptor as OptionDescriptor <sbyte>); return; } if (typeof(T) == typeof(ushort)) { GetOpt(ref command, descriptor as OptionDescriptor <ushort>); return; } if (typeof(T) == typeof(uint)) { GetOpt(ref command, descriptor as OptionDescriptor <uint>); return; } if (typeof(T) == typeof(ulong)) { GetOpt(ref command, descriptor as OptionDescriptor <ulong>); return; } throw new NotImplementedException("Type " + default(T).GetType() + " is not supported!"); }