public int Run() { try { var a = new Args(this.Arguments); if (OnException != null) { a.OnException = (e) => { return(this.OnException(e)); }; } var entryAssembly = Assembly.GetCallingAssembly(); var programName = this.Application.GetType().Assembly.GetName().Name; var rootCommand = ObjectCommand.Create(programName, ObjectProvider.Create(new Starter(this.Application, a))); return(rootCommand.Invoke(a)); } catch (ParseError ex) { Console.Error.WriteLine(ex.Message); return(-1); } catch (Exception ex) { Console.Error.WriteLine(ex); return(-1); } }
static IEnumerable <ICommand> GetCommands(ICommand parent, IObjectProvider containingObject, MemberInfo m, IEnumerable <IOption> inheritedOptions) { if (m.GetCustomAttribute <ModuleAttribute>() != null) { return(GetCommands(parent, ObjectProvider.ResolveNow(containingObject, m), inheritedOptions)); } return(ObjectCommand.Create(parent, m, containingObject).ToEnumerable()); }