/// <summary> /// Validates the args. /// </summary> /// <param name="args"></param> /// <returns></returns> public static BoolMsgItem Validate(FSArgs args) { var isOutFileNeeded = (args.Tokenize || args.Nodes); if (string.IsNullOrEmpty(args.FilePath)) { return(new BoolMsgItem(false, "File path was not supplied", null)); } if (!File.Exists(args.FilePath)) { return(new BoolMsgItem(false, "File path : " + args.FilePath + " does NOT exist.", null)); } if (!string.IsNullOrEmpty(args.Logs) && !Directory.Exists(args.Logs)) { return(new BoolMsgItem(false, "Log directory : " + args.Logs + " does NOT exist.", null)); } if (!string.IsNullOrEmpty(args.Plugins) && !IsValidPluginGroup(args.Plugins)) { return(new BoolMsgItem(false, "Plugin group : " + args.Plugins + " is NOT valid. e.g. 'sys', 'all', 'explicit:<pluginname1>,<pluginname2>..etc'", null)); } if (isOutFileNeeded && string.IsNullOrEmpty(args.Out)) { return(new BoolMsgItem(false, "Out file path was not supplied", null)); } return(new BoolMsgItem(true, string.Empty, null)); }
/// <summary> /// Execute the core logic of the application. /// </summary> /// <remarks>Note this does not need to be inside of a try-catch /// if using the ApplicationDecorator.</remarks> public override BoolMessageItem Execute() { var args = this.Settings.ArgsReciever as FSArgs; _fsargs = args; // 1. validate the args var result = FSHelper.Validate(_fsargs); if (!result.Success) { HandleValidationFailure(result); return(new BoolMessageItem(1, false, result.Message)); } // 2. Create interpreter var interpreter = CreateInterpreter(); // 3. Execute the code. ExecuteCode(interpreter); // 4. Get the result of the execution var runResult = interpreter.Result; FSHelper.WriteScriptStatus(runResult.Success, runResult.Message); return(new BoolMessageItem(null, runResult.Success, runResult.Message)); }