Permalink
Browse files

Run() now has return codes

  • Loading branch information...
1 parent 74ae529 commit 2d9a1c179212800c4b0a370bff8d0a0f8816b71f @adrianaisemberg committed May 7, 2012
Showing with 40 additions and 39 deletions.
  1. +38 −38 CLAP/Parser.cs
  2. +2 −1 ConsoleTest/Program.cs
View
@@ -26,39 +26,39 @@ public Parser(params Type[] types)
/// </summary>
/// <param name="args">The user arguments</param>
/// <param name="targets">The instances of the verb classes</param>
- public static void Run(string[] args, params object[] targets)
+ public static int Run(string[] args, params object[] targets)
{
Debug.Assert(targets.Any());
Debug.Assert(targets.All(t => t != null));
var p = new Parser(targets.Select(t => t.GetType()).ToArray());
- ((MultiParser)p).RunTargets(args, targets);
+ return ((MultiParser)p).RunTargets(args, targets);
}
/// <summary>
/// Executes a generic static parser of a specified type
/// </summary>
/// <typeparam name="T">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
- public static void Run<T>(string[] args)
- { new Parser<T>().RunStatic(args); }
+ public static int Run<T>(string[] args)
+ { return new Parser<T>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of a specified type
/// </summary>
/// <typeparam name="T">The type of the parser</typeparam>
/// <param name="args">The user arguments</param>
/// <param name="t">An instance of the verb class</param>
- public static void Run<T>(string[] args, T t)
- { new Parser<T>().RunTargets(args, t); }
+ public static int Run<T>(string[] args, T t)
+ { return new Parser<T>().RunTargets(args, t); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2>(string[] args)
- { new Parser<T1, T2>().RunStatic(args); }
+ public static int Run<T1, T2>(string[] args)
+ { return new Parser<T1, T2>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -68,15 +68,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="args">The user arguments</param>
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
- public static void Run<T1, T2>(string[] args, T1 t1, T2 t2)
- { new Parser<T1, T2>().RunTargets(args, t1, t2); }
+ public static int Run<T1, T2>(string[] args, T1 t1, T2 t2)
+ { return new Parser<T1, T2>().RunTargets(args, t1, t2); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3>(string[] args)
- { new Parser<T1, T2, T3>().RunStatic(args); }
+ public static int Run<T1, T2, T3>(string[] args)
+ { return new Parser<T1, T2, T3>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -88,15 +88,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="t1">An instance of the verb class</param>
/// <param name="t2">An instance of the verb class</param>
/// <param name="t3">An instance of the verb class</param>
- public static void Run<T1, T2, T3>(string[] args, T1 t1, T2 t2, T3 t3)
- { new Parser<T1, T2, T3>().RunTargets(args, t1, t2, t3); }
+ public static int Run<T1, T2, T3>(string[] args, T1 t1, T2 t2, T3 t3)
+ { return new Parser<T1, T2, T3>().RunTargets(args, t1, t2, t3); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3, T4>(string[] args)
- { new Parser<T1, T2, T3, T4>().RunStatic(args); }
+ public static int Run<T1, T2, T3, T4>(string[] args)
+ { return new Parser<T1, T2, T3, T4>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -110,15 +110,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="t2">An instance of the verb class</param>
/// <param name="t3">An instance of the verb class</param>
/// <param name="t4">An instance of the verb class</param>
- public static void Run<T1, T2, T3, T4>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4)
- { new Parser<T1, T2, T3, T4>().RunTargets(args, t1, t2, t3, t4); }
+ public static int Run<T1, T2, T3, T4>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4)
+ { return new Parser<T1, T2, T3, T4>().RunTargets(args, t1, t2, t3, t4); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3, T4, T5>(string[] args)
- { new Parser<T1, T2, T3, T4, T5>().RunStatic(args); }
+ public static int Run<T1, T2, T3, T4, T5>(string[] args)
+ { return new Parser<T1, T2, T3, T4, T5>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -134,15 +134,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="t3">An instance of the verb class</param>
/// <param name="t4">An instance of the verb class</param>
/// <param name="t5">An instance of the verb class</param>
- public static void Run<T1, T2, T3, T4, T5>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
- { new Parser<T1, T2, T3, T4, T5>().RunTargets(args, t1, t2, t3, t4, t5); }
+ public static int Run<T1, T2, T3, T4, T5>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+ { return new Parser<T1, T2, T3, T4, T5>().RunTargets(args, t1, t2, t3, t4, t5); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3, T4, T5, T6>(string[] args)
- { new Parser<T1, T2, T3, T4, T5, T6>().RunStatic(args); }
+ public static int Run<T1, T2, T3, T4, T5, T6>(string[] args)
+ { return new Parser<T1, T2, T3, T4, T5, T6>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -160,15 +160,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="t4">An instance of the verb class</param>
/// <param name="t5">An instance of the verb class</param>
/// <param name="t6">An instance of the verb class</param>
- public static void Run<T1, T2, T3, T4, T5, T6>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
- { new Parser<T1, T2, T3, T4, T5, T6>().RunTargets(args, t1, t2, t3, t4, t5, t6); }
+ public static int Run<T1, T2, T3, T4, T5, T6>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+ { return new Parser<T1, T2, T3, T4, T5, T6>().RunTargets(args, t1, t2, t3, t4, t5, t6); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3, T4, T5, T6, T7>(string[] args)
- { new Parser<T1, T2, T3, T4, T5, T6, T7>().RunStatic(args); }
+ public static int Run<T1, T2, T3, T4, T5, T6, T7>(string[] args)
+ { return new Parser<T1, T2, T3, T4, T5, T6, T7>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -188,15 +188,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="t5">An instance of the verb class</param>
/// <param name="t6">An instance of the verb class</param>
/// <param name="t7">An instance of the verb class</param>
- public static void Run<T1, T2, T3, T4, T5, T6, T7>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
- { new Parser<T1, T2, T3, T4, T5, T6, T7>().RunTargets(args, t1, t2, t3, t4, t5, t6, t7); }
+ public static int Run<T1, T2, T3, T4, T5, T6, T7>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+ { return new Parser<T1, T2, T3, T4, T5, T6, T7>().RunTargets(args, t1, t2, t3, t4, t5, t6, t7); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3, T4, T5, T6, T7, T8>(string[] args)
- { new Parser<T1, T2, T3, T4, T5, T6, T7, T8>().RunStatic(args); }
+ public static int Run<T1, T2, T3, T4, T5, T6, T7, T8>(string[] args)
+ { return new Parser<T1, T2, T3, T4, T5, T6, T7, T8>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -218,15 +218,15 @@ public static void Run<T>(string[] args, T t)
/// <param name="t6">An instance of the verb class</param>
/// <param name="t7">An instance of the verb class</param>
/// <param name="t8">An instance of the verb class</param>
- public static void Run<T1, T2, T3, T4, T5, T6, T7, T8>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
- { new Parser<T1, T2, T3, T4, T5, T6, T7, T8>().RunTargets(args, t1, t2, t3, t4, t5, t6, t7, t8); }
+ public static int Run<T1, T2, T3, T4, T5, T6, T7, T8>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+ { return new Parser<T1, T2, T3, T4, T5, T6, T7, T8>().RunTargets(args, t1, t2, t3, t4, t5, t6, t7, t8); }
/// <summary>
/// Executes a generic static parser of some specified types
/// </summary>
/// <param name="args">The user arguments</param>
- public static void Run<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string[] args)
- { new Parser<T1, T2, T3, T4, T5, T6, T7, T8, T9>().RunStatic(args); }
+ public static int Run<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string[] args)
+ { return new Parser<T1, T2, T3, T4, T5, T6, T7, T8, T9>().RunStatic(args); }
/// <summary>
/// Executes a generic parser of some specified types
@@ -250,8 +250,8 @@ public static void Run<T>(string[] args, T t)
/// <param name="t7">An instance of the verb class</param>
/// <param name="t8">An instance of the verb class</param>
/// <param name="t9">An instance of the verb class</param>
- public static void Run<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
- { new Parser<T1, T2, T3, T4, T5, T6, T7, T8, T9>().RunTargets(args, t1, t2, t3, t4, t5, t6, t7, t8, t9); }
+ public static int Run<T1, T2, T3, T4, T5, T6, T7, T8, T9>(string[] args, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+ { return new Parser<T1, T2, T3, T4, T5, T6, T7, T8, T9>().RunTargets(args, t1, t2, t3, t4, t5, t6, t7, t8, t9); }
}
/// <summary>
View
@@ -17,8 +17,9 @@ static int Main(string[] args)
//Parser.RunConsole<TheApp>(args);
//Parser.RunConsole<ClapApp, SomeApp, TheApp>(args);
- return Parser.RunConsole<SomeApp>(args);
+ //return Parser.RunConsole<SomeApp>(args);
//Parser.Run<SomeApp, ClapApp>(args);
+ return Parser.Run<DefaultApp>(args);
}
}

0 comments on commit 2d9a1c1

Please sign in to comment.