public void CommandOptions_Lack_Of_Arguments_Test() { var options = new CommandOptions(); var parser = new CommandLine.CommandLineParser(); var parsed = parser.ParseArguments(new[] { "-m", "-s"}, options); Assert.AreEqual(false, parsed); }
public void CommandOptions_Mode_Source_Destination_Test() { var options = new CommandOptions(); var parser = new CommandLine.CommandLineParser(); parser.ParseArguments(new[] { "-m", "backup", "-s", "mySource", "-d", "myDestination" }, options); Assert.AreEqual("backup", options.Mode); Assert.AreEqual("mySource", options.Source); Assert.AreEqual("myDestination", options.Destination); }
public override void Invoke(CommandOptions options) { var getKeyCommandOptions = TryConvertToSpecificOptions<FindByKeyCommandOptions>(options); IDictionary<string, IDictionary<string, string>> result; using (var conn = ConnectionProvider.GetConnection()) { result = conn.GetColumns(new[] {getKeyCommandOptions.Key}); } OutputReporter.OutputColumns(result); }
public override void Invoke(CommandOptions options) { var findOptions = TryConvertToSpecificOptions<FindByColumnsCommandOptions>(options); var columnCriteria = GetColumnCriteria(findOptions); var query = BuildTokyoTyrantQuery(columnCriteria); var result = QueryRecords(query); OutputReporter.OutputColumns(result); }
public void Invoke(CommandOptions options) { _outputReporter.Report("--findby-key keyValue"); _outputReporter.Report("Returns all columns for a given key."); _outputReporter.Report(""); _outputReporter.Report("--findby-columns columnName1:columnValue1 [columnName2:columnValue2]"); _outputReporter.Report("Returns all keys and columns that have columns with values that match exactly to columnValue AND columnValue2"); _outputReporter.Report(""); _outputReporter.Report("--delete-key keyValue"); _outputReporter.Report("Deletes a key and all columns assosiated with it."); _outputReporter.Report(""); _outputReporter.Report("--update-key keyValue columnName1:columnValue1 [columnName2:columnValue2]"); _outputReporter.Report("Updates column valus for a given key. If column does not exist it is created. If column already has data, it is overwritten."); _outputReporter.Report(""); }
public override void Invoke(CommandOptions options) { var updateOptions = TryConvertToSpecificOptions<UpdateKeyCommandOptions>(options); IDictionary<string, string> parsedColumnValues = ParseColumnData(updateOptions); using (var conn = ConnectionProvider.GetConnection()) { IDictionary<string, IDictionary<string, string>> keysColumns = conn.GetColumns(new[] {updateOptions.Key}); if (keysColumns.Any()) { UpdateExistingColumns(parsedColumnValues, conn, updateOptions, keysColumns); } else { conn.PutColumns(updateOptions.Key, parsedColumnValues, true); } } }
/// <summary> /// Parse the CommandOptions into the Properties on the command. /// </summary> /// <param name="values"></param> protected override void ParseCommandArguments(CommandOptions values) { base.ParseCommandArguments(values); if (values.Arguments.Count > 0) { this.FunctionName = values.Arguments[0]; } Tuple <CommandOption, CommandOptionValue> tuple; if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_NAME.Switch)) != null) { this.FunctionName = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_DESCRIPTION.Switch)) != null) { this.Description = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_PUBLISH.Switch)) != null) { this.Publish = tuple.Item2.BoolValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_HANDLER.Switch)) != null) { this.Handler = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_MEMORY_SIZE.Switch)) != null) { this.MemorySize = tuple.Item2.IntValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_ROLE.Switch)) != null) { this.Role = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_TIMEOUT.Switch)) != null) { this.Timeout = tuple.Item2.IntValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_RUNTIME.Switch)) != null) { this.Runtime = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_LAYERS.Switch)) != null) { this.LayerVersionArns = tuple.Item2.StringValues; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_TAGS.Switch)) != null) { this.Tags = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_SUBNETS.Switch)) != null) { this.SubnetIds = tuple.Item2.StringValues; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_SECURITY_GROUPS.Switch)) != null) { this.SecurityGroupIds = tuple.Item2.StringValues; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_DEADLETTER_TARGET_ARN.Switch)) != null) { this.DeadLetterTargetArn = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_TRACING_MODE.Switch)) != null) { this.TracingMode = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_ENVIRONMENT_VARIABLES.Switch)) != null) { this.EnvironmentVariables = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_APPEND_ENVIRONMENT_VARIABLES.Switch)) != null) { this.AppendEnvironmentVariables = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_KMS_KEY_ARN.Switch)) != null) { this.KMSKeyArn = tuple.Item2.StringValue; } }
private bool RunCommand(string CommandLine, string Input, HandleOutputDelegate HandleOutput, CommandOptions Options, TextWriter Log) { string FullCommandLine = GetFullCommandLine(CommandLine, Options); bool bResult = true; Log.WriteLine("p4> p4.exe {0}", FullCommandLine); if(Utility.ExecuteProcess("p4.exe", FullCommandLine, Input, Line => { bResult &= ParseCommandOutput(Line, HandleOutput, Options); }) != 0 && !Options.HasFlag(CommandOptions.IgnoreExitCode)) { bResult = false; } return bResult; }
protected override void Load() { try { var stopwatch = Stopwatch.StartNew(); Instance = this; try { var essPermProvider = new EssentialsPermissionsProvider(); R.Permissions = essPermProvider; } catch (Exception ex) { Console.Error.WriteLine(ex); } R.Plugins.OnPluginsLoaded += OverrideCommands; TaskExecutor = new EssentialsTaskExecutor(); SteamGameServer.SetKeyValue("essversion", PLUGIN_VERSION); Logger = new ConsoleLogger("[uEssentials] "); ConnectedPlayers = new Dictionary <ulong, UPlayer>(); Debug.Listeners.Add(new EssentialsConsoleTraceListener()); Provider.onServerDisconnected += PlayerDisconnectCallback; Provider.onServerConnected += PlayerConnectCallback; Logger.LogInfo("Enabling uEssentials..."); if (Provider.clients.Count > 0) { Provider.clients.ForEach(p => { ConnectedPlayers.Add(p.playerID.steamID.m_SteamID, new UPlayer(UnturnedPlayer.FromSteamPlayer(p))); }); } _folder = Rocket.Core.Environment.PluginsDirectory + "/uEssentials/"; _translationFolder = Folder + "translations/"; _dataFolder = Folder + "data/"; _modulesFolder = Folder + "modules/"; WebResources = new WebResources(); Config = new EssConfig(); var webResourcesPath = Path.Combine(Folder, WebResources.FileName); var configPath = Path.Combine(Folder, Config.FileName); WebResources.Load(webResourcesPath); // Sync web config with local config.json if (WebResources.Loaded.ContainsKey("Config")) { File.WriteAllText(configPath, WebResources.Loaded["Config"]); } Config.Load(configPath); CommandOptions = new CommandOptions(); CommandOptions.Load(Path.Combine(Folder, CommandOptions.FileName)); Updater = new GithubUpdater(); EventManager = new EventManager(); CommandManager = new CommandManager(); ModuleManager = new ModuleManager(); HookManager = new HookManager(); EssLang.Load(); new [] { "Plugin version: ~white~" + PLUGIN_VERSION + BUILD_INFO, "Recommended Rocket version: ~white~" + ROCKET_VERSION, "Recommended Unturned version: ~white~" + UNTURNED_VERSION, "Author: ~white~leonardosnt", "Wiki: ~white~uessentials.github.io", }.ForEach(text => Logger.LogInfo(text, true)); EventManager.RegisterAll(GetType().Assembly); if (!Config.EnableJoinLeaveMessage) { EventManager.Unregister <EssentialsEventHandler>("JoinMessage"); EventManager.Unregister <EssentialsEventHandler>("LeaveMessage"); } // Register all commands from namespace Essentials.Commands CommandManager.RegisterAll("Essentials.Commands"); HookManager.RegisterAll(); HookManager.LoadAll(); if (Config.Economy.UseXp) { EconomyProvider = Optional <IEconomyProvider> .Of(new ExpEconomyProvider()); } else if (HookManager.GetActiveByType <AviEconomyHook>().IsPresent) { EconomyProvider = Optional <IEconomyProvider> .Of(HookManager.GetActiveByType <AviEconomyHook>().Value); } else if (HookManager.GetActiveByType <UconomyHook>().IsPresent) { EconomyProvider = Optional <IEconomyProvider> .Of(HookManager.GetActiveByType <UconomyHook>().Value); } else { EconomyProvider = Optional <IEconomyProvider> .Empty(); } LoadNativeModules(); Logger.LogInfo($"Loaded {CommandManager.Commands.Count()} commands"); Logger.LogInfo("Loading modules..."); ModuleManager.LoadAll(ModulesFolder); Logger.LogInfo($"Loaded {ModuleManager.RunningModules.Count(t => !(t is NativeModule))} modules"); if (Config.AutoAnnouncer.Enabled) { Config.AutoAnnouncer.Start(); } if (Config.AutoCommands.Enabled) { Config.AutoCommands.Start(); } if (!Config.Updater.AlertOnJoin) { EventManager.Unregister <EssentialsEventHandler>("UpdateAlert"); } if (Config.ServerFrameRate != -1) { var frameRate = Config.ServerFrameRate; if (Config.ServerFrameRate < -1) { frameRate = -1; // Set to default } UnityEngine.Application.targetFrameRate = frameRate; } if (Config.DisabledCommands.Count != 0) { Config.DisabledCommands.ForEach(cmdName => { var command = CommandManager.GetByName(cmdName); if (command == null || command is CommandEssentials) { Logger.LogWarning($"There is no command named '{cmdName}' to disable."); } else { CommandManager.Unregister(command); Logger.LogInfo($"Disabled command: '{command.Name}'"); } }); } if (Config.EnableTextCommands) { TextCommands = new TextCommands(); var textCommandsFile = Path.Combine(Folder, TextCommands.FileName); TextCommands.Load(textCommandsFile); TextCommands.Commands.ForEach(txtCommand => { CommandManager.Register(new TextCommand(txtCommand)); }); } if (!Config.EnableDeathMessages) { EventManager.Unregister <EssentialsEventHandler>("DeathMessages"); } #if EXPERIMENTAL Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, CAN BE BUGGY."); #endif // Delete useless files generated by Rocket Task.Create() .Id("Delete Xml Files") .Delay(TimeSpan.FromSeconds(1)) .Async() .Action(() => { File.Delete($"{Folder}uEssentials.en.translation.xml"); File.Delete($"{Folder}uEssentials.configuration.xml"); }) .Submit(); CommandWindow.input.onInputText += ReloadCallback; Logger.LogInfo($"Enabled ({stopwatch.ElapsedMilliseconds} ms)"); } catch (Exception e) { var msg = new List <string>() { "An error occurred while enabling uEssentials.", "If this error is not related with wrong configuration please report", "immediatly here https://github.com/uEssentials/uEssentials/issues", "Error: " + e }; if (!Provider.APP_VERSION.EqualsIgnoreCase(UNTURNED_VERSION)) { msg.Add("I detected that you are using a different version of the recommended, " + "please update your uEssentials/Unturned."); msg.Add("If you are using the latest uEssentials release, please wait for update."); } if (Logger == null) { Console.BackgroundColor = ConsoleColor.Red; msg.ForEach(Console.WriteLine); Console.BackgroundColor = ConsoleColor.White; } else { msg.ForEach(Logger.LogError); } } #if !DEV Analytics.SendEvent($"ServerInit"); #endif #if DEV Console.Title = "Unturned Server"; #else CheckUpdates(); #endif }
public ValueTask <RegiConfig> CreateConfigurationAsync(IEnumerable <Project> projects, CommandOptions options) { var config = new RegiConfig { Projects = projects.ToList() }; return(new ValueTask <RegiConfig>(config)); }
protected override void Load() { try { var stopwatch = Stopwatch.StartNew(); Instance = this; R.Plugins.OnPluginsLoaded += OverrideCommands; TaskExecutor = new EssentialsTaskExecutor(); SteamGameServer.SetKeyValue("essversion", PLUGIN_VERSION); Logger = new ConsoleLogger("[uEssentials] "); _consoleTraceListener = new EssentialsConsoleTraceListener(); Debug.Listeners.Add(_consoleTraceListener); Provider.onServerDisconnected += PlayerDisconnectCallback; Provider.onServerConnected += PlayerConnectCallback; Logger.LogInfo("Enabling uEssentials..."); new[] { "Plugin version: ~white~" + PLUGIN_VERSION + BUILD_INFO, "Recommended Rocket version: ~white~" + ROCKET_VERSION, "Recommended Unturned version: ~white~" + UNTURNED_VERSION, "Author: ~white~leonardosnt", "Wiki: ~white~uessentials.github.io", }.ForEach(text => Logger.LogInfo(text, true)); if (Provider.clients.Count > 0) { Provider.clients.ForEach(p => { ConnectedPlayers.Add(p.playerID.steamID.m_SteamID, new UPlayer(UnturnedPlayer.FromSteamPlayer(p))); }); } _folder = Rocket.Core.Environment.PluginsDirectory + "/uEssentials/"; _translationFolder = Folder + "translations/"; _dataFolder = Folder + "data/"; _modulesFolder = Folder + "modules/"; CommandOptions = new CommandOptions(); Updater = new GithubUpdater(); EventManager = new EventManager(); CommandManager = new CommandManager(); ModuleManager = new ModuleManager(); HookManager = new HookManager(); WebResources = new WebResources(); Config = new EssConfig(); var webResourcesPath = Path.Combine(Folder, WebResources.FileName); var configPath = Path.Combine(Folder, Config.FileName); WebResources.Load(webResourcesPath); // Sync web config with local config.json if (WebResources.Loaded.ContainsKey("Config")) { File.WriteAllText(configPath, WebResources.Loaded["Config"]); } Config.Load(configPath); CommandOptions.Load(Path.Combine(Folder, CommandOptions.FileName)); EssLang.Load(); EventManager.RegisterAll(GetType().Assembly); // Register all commands from namespace Essentials.Commands CommandManager.RegisterAll("Essentials.Commands"); HookManager.RegisterAll(); HookManager.LoadAll(); // Load after EventManager because we relies on it inside this routine. ConfigPostLoad(); LoadNativeModules(); Logger.LogInfo("Loading modules..."); ModuleManager.LoadAll(ModulesFolder); Logger.LogInfo($"Loaded {ModuleManager.RunningModules.Count(t => !(t is NativeModule))} modules"); // We log it here because the modules being loaded above can // register commands. Logger.LogInfo($"Loaded {CommandManager.Commands.Count()} commands"); #if EXPERIMENTAL Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, IT CAN BE BUGGY."); Logger.LogWarning("THIS IS AN EXPERIMENTAL BUILD, IT CAN BE BUGGY."); #endif // Delete useless files generated by Rocket Task.Create() .Id("Delete Xml Files") .Delay(TimeSpan.FromSeconds(1)) .Async() .Action(() => { File.Delete($"{Folder}uEssentials.en.translation.xml"); File.Delete($"{Folder}uEssentials.configuration.xml"); }) .Submit(); // If _wasLoadedBefore, then it means that uEssentials is // being reloaded, and it also means that R.Plugins.OnPluginsLoaded will not be called, // consequently OverrideCommands will not be called too // so we need to call it here. if (_wasLoadedBefore) { OverrideCommands(); } _wasLoadedBefore = true; CommandWindow.input.onInputText += ReloadCallback; Logger.LogInfo($"Enabled ({stopwatch.ElapsedMilliseconds} ms)"); } catch (Exception e) { string[] messages = { "An error occurred while enabling uEssentials.", "If this error is not related with wrong configuration, please report", "it here https://github.com/uEssentials/uEssentials/issues", "Error: " + e }; if (Logger == null) { Console.BackgroundColor = ConsoleColor.Red; messages.ForEach(Console.WriteLine); Console.BackgroundColor = ConsoleColor.White; } else { messages.ForEach(m => Logger.LogError(m)); } } #if !DEV Analytics.SendEvent($"ServerInit"); #endif #if DEV Console.Title = "Unturned Server"; #else CheckUpdates(); #endif }
protected override void ApplyFrameworkOptions(StringBuilder builder, string command, Project project, CommandOptions options) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (!string.IsNullOrWhiteSpace(project.Source)) { if (command == FrameworkCommands.DotnetCore.Restore || command == FrameworkCommands.DotnetCore.Run || command == FrameworkCommands.DotnetCore.Build || command == FrameworkCommands.DotnetCore.Publish) { builder.AppendCliOption($"--source {project.Source}"); } } base.ApplyFrameworkOptions(builder, command, project, options); }
internal void ParseCommandArguments(CommandOptions values) { Tuple <CommandOption, CommandOptionValue> tuple; if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION.Switch)) != null) { this.Configuration = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK.Switch)) != null) { this.TargetFramework = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_EB_APPLICATION.Switch)) != null) { this.Application = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_EB_ENVIRONMENT.Switch)) != null) { this.Environment = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_APP_PATH.Switch)) != null) { this.UrlPath = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_IIS_WEBSITE.Switch)) != null) { this.IISWebSite = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_WAIT_FOR_UPDATE.Switch)) != null) { this.WaitForUpdate = tuple.Item2.BoolValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_EB_VERSION_LABEL.Switch)) != null) { this.VersionLabel = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_EB_TAGS.Switch)) != null) { this.Tags = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_EB_ADDITIONAL_OPTIONS.Switch)) != null) { this.AdditionalOptions = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_SOLUTION_STACK.Switch)) != null) { this.SolutionStack = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_ENVIRONMENT_TYPE.Switch)) != null) { this.EnvironmentType = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_CNAME_PREFIX.Switch)) != null) { this.CNamePrefix = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_INSTANCE_TYPE.Switch)) != null) { this.InstanceType = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_EC2_KEYPAIR.Switch)) != null) { this.EC2KeyPair = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_HEALTH_CHECK_URL.Switch)) != null) { this.HealthCheckUrl = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_INSTANCE_PROFILE.Switch)) != null) { this.InstanceProfile = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_SERVICE_ROLE.Switch)) != null) { this.ServiceRole = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_ENABLE_XRAY.Switch)) != null) { this.EnableXRay = tuple.Item2.BoolValue; } }
private bool RunCommand(string CommandLine, out List<PerforceClientRecord> ClientRecords, CommandOptions Options, TextWriter Log) { List<Dictionary<string, string>> TagRecords; if(!RunCommand(CommandLine, out TagRecords, Options, Log)) { ClientRecords = null; return false; } else { ClientRecords = TagRecords.Select(x => new PerforceClientRecord(x)).ToList(); return true; } }
public override void Invoke(CommandOptions options) { var findOptions = TryConvertToSpecificOptions<FindKeyCommandOptions>(options); }
private bool RunCommand(string CommandLine, CommandOptions Options, TextWriter Log) { List<string> Lines; return RunCommand(CommandLine, out Lines, Options, Log); }
private bool RunCommand(string CommandLine, out List<Dictionary<string, string>> TagRecords, CommandOptions Options, TextWriter Log) { List<string> Lines; if(!RunCommand("-ztag " + CommandLine, PerforceOutputChannel.TaggedInfo, out Lines, Options, Log)) { TagRecords = null; return false; } List<Dictionary<string, string>> LocalOutput = new List<Dictionary<string, string>>(); using(PerforceTagRecordParser Parser = new PerforceTagRecordParser(Record => LocalOutput.Add(Record))) { foreach(string Line in Lines) { Parser.OutputLine(Line); } } TagRecords = LocalOutput; return true; }
private static void Main(string[] args) { var options = new CommandOptions(args); // Configuration 읽기 Configuration.Load(options.Get("--config", @"Config.xml")); // 설정 덮어쓰기 options.Override("--port", ref Configuration.Port); options.Override("--pylonHost", ref Configuration.PylonHost); options.Override("--pylonPort", ref Configuration.PylonPort); options.Override("--mongodb", ref Configuration.UseMongoDatabase); options.Override("--xmldb", ref Configuration.UseXmlDatabase); options.Override("--sync", ref Configuration.UseDatabaseSync); // Sync를 사용할 경우에는 모든 EntityBind가 등록되어야 한다. if (Configuration.UseDatabaseSync) { Configuration.UseMongoDatabase = true; Configuration.UseXmlDatabase = true; } // Datasheet 읽기 DataCenter.Instance.Load(Configuration.DatasheetFileDirectory, Configuration.DatasheetFilePattern); // 모든 handler 등록 (Sync 쓸 때는 Handler 실행 안되도록 한다.) if (!Configuration.UseDatabaseSync) HandlerHelper.Register(Assembly.GetExecutingAssembly()); // System Entity 생성 EntityManager.Instance.Create(EntityManager.SystemId, DataCenter.Instance.GetCreateInfo(EntityTemplate.Ids.System)); // Database 연결 if (Configuration.UseMongoDatabase) { EntityBinder.Instance.AddBinder(new MongoBind( Configuration.MongoDatabaseHost, Configuration.MongoDatabasePort, Configuration.MongoDatabaseName, Configuration.MongoDatabaseCollectionName)); } if (Configuration.UseXmlDatabase) EntityBinder.Instance.AddBinder(new XmlBind(Configuration.XmlDatabaseDirectory)); if (Configuration.UseDatabaseSync) { EntityBinder.Instance.Sync(Configuration.SyncFromDatabaseType, Configuration.SyncToDatabaseType); Logger.Write("Sync Completed."); Console.ReadLine(); return; } // EntityManager caching 및 준비 EntityBinder.Instance.ForEach(each => { if (each.Has<Player>()) { each.Get<Player>().Logged = false; if (each.Has<Nameplate>()) { var playerName = each.Get<Nameplate>().Name; NameCache.Instance.Add(playerName, each.Id); } } if (!each.Has<Player>() && each.Has<Pos>()) PositionSystem.Global.Appear(each); EntityManager.Instance.Add(each); }); EntityManager.Instance.TrimIdSerial(); Logger.Write("Player [{0}] loaded.", NameCache.Instance.Count); // Network 시작 var listener = MessageSessionManager.Instance.CreateListener(); Task.Factory.StartNew(() => listener.Start(Configuration.Port), TaskCreationOptions.LongRunning); // Pylon 등록 PylonConnector.Instance.Start(); Logger.Write("Server is ready."); Console.ReadLine(); }
private bool RunCommand(string CommandLine, out List<string> Lines, CommandOptions Options, TextWriter Log) { return RunCommand(CommandLine, PerforceOutputChannel.Info, out Lines, Options, Log); }
private string GetFullCommandLine(string CommandLine, CommandOptions Options) { StringBuilder FullCommandLine = new StringBuilder(); if(ServerAndPort != null) { FullCommandLine.AppendFormat("-p{0} ", ServerAndPort); } if(UserName != null) { FullCommandLine.AppendFormat("-u{0} ", UserName); } if(!Options.HasFlag(CommandOptions.NoClient) && ClientName != null) { FullCommandLine.AppendFormat("-c{0} ", ClientName); } if(!Options.HasFlag(CommandOptions.NoChannels)) { FullCommandLine.Append("-s "); } FullCommandLine.Append(CommandLine); return FullCommandLine.ToString(); }
/// <summary> /// Run 'commandLine', sending the output to the console, and wait for the Command to complete. /// This simulates what batch filedo when executing their commands. It is a bit more verbose /// by default, however /// </summary> /// <param variable="commandLine">The Command lineNumber to run as a subprocess</param> /// <param variable="options">Additional qualifiers that control how the process is run</param> /// <returns>A Command structure that can be queried to determine ExitCode, Output, etc.</returns> public static Command RunToConsole(string commandLine, CommandOptions options) { return(Run(commandLine, options.Clone().AddOutputStream(Console.Out).AddErrorStream(Console.Error))); }
public Route(CommandOptions options, ICommand handler) { Options = options; Handler = handler; }
/// <summary> /// Parse the CommandOptions into the Properties on the command. /// </summary> /// <param name="values"></param> protected override void ParseCommandArguments(CommandOptions values) { base.ParseCommandArguments(values); this.DeployEnvironmentOptions.ParseCommandArguments(values); }
public void LoadFromOptions(CommandOptions options) { Aliases = options.Aliases?.ToArray() ?? new string[0]; _parameters = options.Parameters.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); }
private static bool IgnoreCommandOutput(string Text, CommandOptions Options) { if(Text.StartsWith("exit: ") || Text.StartsWith("info2: ") || Text.Length == 0) { return true; } else if(Options.HasFlag(CommandOptions.IgnoreFilesUpToDateError) && Text.StartsWith("error: ") && Text.EndsWith("- file(s) up-to-date.")) { return true; } else if(Options.HasFlag(CommandOptions.IgnoreNoSuchFilesError) && Text.StartsWith("error: ") && Text.EndsWith(" - no such file(s).")) { return true; } else if(Options.HasFlag(CommandOptions.IgnoreFilesNotInClientViewError) && Text.StartsWith("error: ") && Text.EndsWith("- file(s) not in client view.")) { return true; } else if(Options.HasFlag(CommandOptions.IgnoreFilesNotOpenedOnThisClientError) && Text.StartsWith("error: ") && Text.EndsWith(" - file(s) not opened on this client.")) { return true; } return false; }
public Task RegisterMessageProcessor <TMessageProcessor>(CommandOptions options = null) where TMessageProcessor : IMessageProcessor => RegisterMessageProcessor(typeof(TMessageProcessor), options);
public override void Invoke(CommandOptions options) { var deleteOptions = TryConvertToSpecificOptions<DeleteKeyCommandOptions>(options); var connection = ConnectionProvider.GetConnection(); connection.Delete(deleteOptions.Key); }
public async Task <IMessageProcessor> RegisterMessageProcessor(Guid commandId, Type messageProcessorType, CommandOptions options = null) { var processor = _serviceProvider.GetRequiredService(messageProcessorType) as IMessageProcessor; await processor.LoadSettings(commandId, await _channelIdCompletionSource.Task, options); var initTask = Task.Run(async() => { if (_currentContext != null) { await processor.OnUpdateContext(_currentContext); } if (!_commandProcessors.TryAdd(commandId, processor)) { throw new InvalidOperationException("Could not add command, unexpectedly. Id collision ??"); } }); return(processor); }
public EngineModule(CommandOptions options) => Options = options;
public void SaveToOptions(CommandOptions options) { options.Aliases = Aliases.ToArray(); options.Parameters["Message"] = Message; }
private bool RunCommand(string CommandLine, out List <PerforceClientRecord> ClientRecords, CommandOptions Options, TextWriter Log) { List <Dictionary <string, string> > TagRecords; if (!RunCommand(CommandLine, out TagRecords, Options, Log)) { ClientRecords = null; return(false); } else { ClientRecords = TagRecords.Select(x => new PerforceClientRecord(x)).ToList(); return(true); } }
private bool RunCommand(string CommandLine, PerforceOutputChannel Channel, out List<string> Lines, CommandOptions Options, TextWriter Log) { string FullCommandLine = GetFullCommandLine(CommandLine, Options); Log.WriteLine("p4> p4.exe {0}", FullCommandLine); List<string> RawOutputLines; if(Utility.ExecuteProcess("p4.exe", FullCommandLine, null, out RawOutputLines) != 0 && !Options.HasFlag(CommandOptions.IgnoreExitCode)) { Lines = null; return false; } bool bResult = true; if(Options.HasFlag(CommandOptions.NoChannels)) { Lines = RawOutputLines; } else { List<string> LocalLines = new List<string>(); foreach(string RawOutputLine in RawOutputLines) { bResult &= ParseCommandOutput(RawOutputLine, Line => { if(Line.Channel == Channel){ LocalLines.Add(Line.Text); return true; } else { Log.WriteLine(Line.Text); return Line.Channel != PerforceOutputChannel.Error; } }, Options); } Lines = LocalLines; } return bResult; }
public virtual async Task <IProcessorSettings> LoadSettings(Guid processorId, string broadcasterId, CommandOptions options) { Id = processorId; var settings = new ProcessorSettingsBase(); settings.BroadcasterId = broadcasterId; settings.LoadFromOptions(options); await OnChangeSettings(settings); return(settings); }
private bool RunCommand(string CommandLine, out List <Dictionary <string, string> > TagRecords, CommandOptions Options, TextWriter Log) { List <string> Lines; if (!RunCommand("-ztag " + CommandLine, PerforceOutputChannel.TaggedInfo, out Lines, Options, Log)) { TagRecords = null; return(false); } List <Dictionary <string, string> > LocalOutput = new List <Dictionary <string, string> >(); using (PerforceTagRecordParser Parser = new PerforceTagRecordParser(Record => LocalOutput.Add(Record))) { foreach (string Line in Lines) { Parser.OutputLine(Line); } } TagRecords = LocalOutput; return(true); }
public Task <IMessageProcessor> RegisterMessageProcessor(Type messageProcessorType, CommandOptions options = null) { var newCommandId = options?.Id ?? Guid.NewGuid(); return(RegisterMessageProcessor(newCommandId, messageProcessorType, options)); }
private bool RunCommand(string CommandLine, CommandOptions Options, TextWriter Log) { List <string> Lines; return(RunCommand(CommandLine, out Lines, Options, Log)); }
public DatabaseHelper() { this.Schemas = this.GetSchemas(); this.QueryOptions = this.GetQueryOptions(); this.CommandOptions = this.GetCommandOptions(); }
private bool RunCommand(string CommandLine, out List <string> Lines, CommandOptions Options, TextWriter Log) { return(RunCommand(CommandLine, PerforceOutputChannel.Info, out Lines, Options, Log)); }
/// <summary> /// Returns a value indicating if this command has the specified /// <paramref name="option"/> applied. /// </summary> /// <param name="option">The option to test.</param> /// <returns><see langword="true"/> if this command as the specified /// <paramref name="option"/> applied, otherwise; <see langword="false"/>.</returns> public bool HasOption(CommandOptions option) { return((this.Options & option) == option); }
private bool RunCommand(string CommandLine, PerforceOutputChannel Channel, out List <string> Lines, CommandOptions Options, TextWriter Log) { string FullCommandLine = GetFullCommandLine(CommandLine, Options); Log.WriteLine("p4> p4.exe {0}", FullCommandLine); List <string> RawOutputLines; if (Utility.ExecuteProcess("p4.exe", FullCommandLine, null, out RawOutputLines) != 0 && !Options.HasFlag(CommandOptions.IgnoreExitCode)) { Lines = null; return(false); } bool bResult = true; if (Options.HasFlag(CommandOptions.NoChannels)) { Lines = RawOutputLines; } else { List <string> LocalLines = new List <string>(); foreach (string RawOutputLine in RawOutputLines) { bResult &= ParseCommandOutput(RawOutputLine, Line => { if (Line.Channel == Channel) { LocalLines.Add(Line.Text); return(true); } else { Log.WriteLine(Line.Text); return(Line.Channel != PerforceOutputChannel.Error); } }, Options); } Lines = LocalLines; } return(bResult); }
static IEnumerable <CommandBaseTests.TestArgs <AsyncCommand <T> > > GetTestArgs <T>( [NotNull] CommandBaseTests.ReentrancyContainer <AsyncCommand <T> > container, [NotNull] Func <T, Task> execute, [NotNull] Func <T, CancellationToken, Task> executeWithCancellationToken, [NotNull] Func <T, CommandExecutionController, CancellationToken, Task> executeWithController) { var nonDefaultOptions = new CommandOptions(false); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(execute, options: nonDefaultOptions), true, false, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(execute, arg => true, nonDefaultOptions), true, false, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(execute, arg => false, nonDefaultOptions), false, false, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(execute), true, true, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(execute, arg => true), true, true, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(execute, arg => false), false, true, container)); yield return (CommandBaseTests.TestArgs.Create( new AsyncCommand <T>(executeWithCancellationToken, options: nonDefaultOptions), true, false, container)); yield return (CommandBaseTests.TestArgs.Create( new AsyncCommand <T>(executeWithCancellationToken, arg => true, nonDefaultOptions), true, false, container)); yield return (CommandBaseTests.TestArgs.Create( new AsyncCommand <T>(executeWithCancellationToken, arg => false, nonDefaultOptions), false, false, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithCancellationToken), true, true, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithCancellationToken, arg => true), true, true, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithCancellationToken, arg => false), false, true, container)); yield return (CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithController, options: nonDefaultOptions), true, false, container)); yield return (CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithController, arg => true, nonDefaultOptions), true, false, container)); yield return (CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithController, arg => false, nonDefaultOptions), false, false, container) ); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithController), true, true, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithController, arg => true), true, true, container)); yield return(CommandBaseTests.TestArgs.Create(new AsyncCommand <T>(executeWithController, arg => false), false, true, container)); }
/// <summary> /// Parse the CommandOptions into the Properties on the command. /// </summary> /// <param name="values"></param> protected override void ParseCommandArguments(CommandOptions values) { base.ParseCommandArguments(values); if (values.Arguments.Count > 0) { this.OutputPackageFileName = values.Arguments[0]; } Tuple <CommandOption, CommandOptionValue> tuple; if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION.Switch)) != null) { this.Configuration = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK.Switch)) != null) { this.TargetFramework = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_OUTPUT_PACKAGE.Switch)) != null) { this.OutputPackageFileName = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_DISABLE_VERSION_CHECK.Switch)) != null) { this.DisableVersionCheck = tuple.Item2.BoolValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS.Switch)) != null) { this.MSBuildParameters = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_LAYERS.Switch)) != null) { this.LayerVersionArns = tuple.Item2.StringValues; } if (!string.IsNullOrEmpty(values.MSBuildParameters)) { if (this.MSBuildParameters == null) { this.MSBuildParameters = values.MSBuildParameters; } else { this.MSBuildParameters += " " + values.MSBuildParameters; } } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_PACKAGE_TYPE.Switch)) != null) { this.PackageType = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_DOCKERFILE.Switch)) != null) { this.DockerFile = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_DOCKER_BUILD_OPTIONS.Switch)) != null) { this.DockerBuildOptions = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_DOCKER_BUILD_WORKING_DIRECTORY.Switch)) != null) { this.DockerBuildWorkingDirectory = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_IMAGE_TAG.Switch)) != null) { this.DockerImageTag = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_HOST_BUILD_OUTPUT.Switch)) != null) { this.HostBuildOutput = tuple.Item2.StringValue; } }
private static void RunOptions(CommandOptions opts) { }
private (string resultFileName, string resultContent) GenerateOptionsToCommand() { this.RemoveCommandOptions("--host"); this.RemoveCommandOptions("--h"); this.RemoveCommandOptions("--port"); this.RemoveCommandOptions("--P"); this.RemoveCommandOptions("--user"); this.RemoveCommandOptions("--u"); this.RemoveCommandOptions("--password"); this.RemoveCommandOptions("--P"); var now = DateTime.Now; var defaultBackupSQLName = $"databases_{Database}_{now:yyyy_MM_dd_HH_mm_ss}.sql"; var dumpFile = Path.Join(DackupContext.Current.TmpPath, defaultBackupSQLName); this.AddCommandOptions("--host", this.Host); this.AddCommandOptions("--port", this.Port.ToString()); this.AddCommandOptions("--user", this.UserName); this.AddCommandOptions("--password", this.Password); if (!CommandOptions.ContainsKey("--databases") && !CommandOptions.ContainsKey("-B")) { this.AddCommandOptions("--databases", this.Database); } if (!CommandOptions.ContainsKey("--result-file") && !CommandOptions.ContainsKey("-r")) { dumpFile = Path.Join(DackupContext.Current.TmpPath, defaultBackupSQLName); this.AddCommandOptions("--result-file", dumpFile); } else { if (CommandOptions.ContainsKey("--result-file")) { dumpFile = Path.Join(DackupContext.Current.TmpPath, $"{now:yyyy_MM_dd_HH_mm_ss}_{CommandOptions["--result-file"]}"); this.AddCommandOptions("--result-file", dumpFile); } else if (CommandOptions.ContainsKey("-r")) { dumpFile = Path.Join(DackupContext.Current.TmpPath, $"{now:yyyy_MM_dd_HH_mm_ss}_{CommandOptions["-r"]}"); this.AddCommandOptions("-r", dumpFile); } } var sb = new StringBuilder(); foreach (var key in CommandOptions.Keys) { var value = CommandOptions[key]; if (string.IsNullOrWhiteSpace(value)) { sb.Append($" {key} "); } else { if (key == "--databases" || key == "-B") { sb.Append($" {key} {value} "); } else { if (key.StartsWith("--")) { sb.Append($" {key}={value} "); } else { sb.Append($" {key} {value} "); } } } } return(dumpFile, sb.ToString()); }
/// <summary> /// Launch a new Command and returns the Command object that can be used to monitor /// the restult. It does not wait for the Command to complete, however you /// can call 'Wait' to do that, or use the 'Run' or 'RunToConsole' methods. */ /// </summary> /// <param variable="commandLine">The Command lineNumber to run as a subprocess</param> /// <param variable="options">Additional qualifiers that control how the process is run</param> /// <returns>A Command structure that can be queried to determine ExitCode, Output, etc.</returns> public Command(string commandLine, CommandOptions options) { this.options = options; this.commandLine = commandLine; // See if the Command is quoted and match it in that case Match m = Regex.Match(commandLine, "^\\s*\"(.*?)\"\\s*(.*)"); if (!m.Success) { m = Regex.Match(commandLine, @"\s*(\S*)\s*(.*)"); // thing before first space is Command } ProcessStartInfo startInfo = new ProcessStartInfo(m.Groups[1].Value, m.Groups[2].Value); process = new Process(); process.StartInfo = startInfo; if (options.start) { startInfo.UseShellExecute = true; } else { if (options.input != null) { startInfo.RedirectStandardInput = true; } startInfo.UseShellExecute = false; startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.ErrorDialog = false; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.CreateNoWindow = true; output = new StringBuilder(); if (options.OutputHandler != null) { process.OutputDataReceived += options.outputHandler; process.ErrorDataReceived += options.outputHandler; } else { process.OutputDataReceived += new DataReceivedEventHandler(OnProcessOutput); process.ErrorDataReceived += new DataReceivedEventHandler(OnProcessOutput); } } if (options.environmentVariables != null) { // copy over the environment variables to the process startInfo options. foreach (string key in options.environmentVariables.Keys) { // look for %VAR% strings in the value and subtitute the appropriate environment variable. string value = options.environmentVariables[key]; if (value != null) { int startAt = 0; for (; ;) { m = new Regex(@"%(\w+)%").Match(value, startAt); if (!m.Success) { break; } string varName = m.Groups[1].Value; string varValue; if (startInfo.EnvironmentVariables.ContainsKey(varName)) { varValue = startInfo.EnvironmentVariables[varName]; } else { varValue = Environment.GetEnvironmentVariable(varName); if (varValue == null) { varValue = ""; } } // replace this instance of the variable with its definition. int varStart = m.Groups[1].Index - 1; // -1 because % chars are not in the group int varEnd = varStart + m.Groups[1].Length + 2; // +2 because % chars are not in the group value = value.Substring(0, varStart) + varValue + value.Substring(varEnd, value.Length - varEnd); startAt = varStart + varValue.Length; } } startInfo.EnvironmentVariables[key] = value; } } startInfo.WorkingDirectory = options.currentDirectory; outputStream = options.outputStream; if (options.outputFile != null) { outputStream = File.CreateText(options.outputFile); } #if false if (options.showCommand && outputStream != null) { // TODO why only for output streams? outputStream.WriteLine("RUN CMD: " + commandLine); } #endif try { process.Start(); } catch (Exception e) { string msg = "Failure starting Process\r\n" + " Exception: " + e.Message + "\r\n" + " Cmd: " + commandLine + "\r\n"; if (Regex.IsMatch(startInfo.FileName, @"^(copy|dir|del|color|set|cd|cdir|md|mkdir|prompt|pushd|popd|start|assoc|ftype)", RegexOptions.IgnoreCase)) { msg += " Cmd " + startInfo.FileName + " implemented by Cmd.exe, fix by prefixing with 'cmd /c'."; } throw new ApplicationException(msg, e); } if (!startInfo.UseShellExecute) { // startInfo asyncronously collecting output process.BeginOutputReadLine(); process.BeginErrorReadLine(); } // Send any input to the Command if (options.input != null) { process.StandardInput.Write(options.input); process.StandardInput.Close(); } }
void HandleKey_SelectAction(int input, bool state) { if (state) return; if (input == KeyConstants.FUNC_C || ((Key)input) == Key.Enter ) { DoCommandAction(); return; } else if (input == KeyConstants.LEFT || input== KeyConstants.RIGHT) { int action = (int)_currentCommand; if (input == KeyConstants.LEFT) action--; else if (input == KeyConstants.RIGHT) action++; if (action > 3) action = 0; else if (action < 0) action = 3; _currentCommand = (CommandOptions)action; } else if(input == KeyConstants.FUNC_COIN_RAD && _currentCommand == CommandOptions.RadX) { _radXTakeCount++; if(_radXTakeCount > 3) _radXTakeCount = 1; } switch (_currentCommand) { case CommandOptions.RadX: WriteInput(_radXTakeCount+" RadX nehmen"); break; case CommandOptions.PureLive: WriteInput("PureLive nehmen"); break; case CommandOptions.RadAway: WriteInput("RadAway nehmen"); break; case CommandOptions.ReadRads: WriteInput("Strahlung messen"); break; } }
/// <summary> /// Parse the CommandOptions into the Properties on the command. /// </summary> /// <param name="values"></param> protected override void ParseCommandArguments(CommandOptions values) { base.ParseCommandArguments(values); if (values.Arguments.Count > 0) { this.StackName = values.Arguments[0]; } Tuple <CommandOption, CommandOptionValue> tuple; if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION.Switch)) != null) { this.Configuration = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK.Switch)) != null) { this.TargetFramework = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_PACKAGE.Switch)) != null) { this.Package = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_S3_BUCKET.Switch)) != null) { this.S3Bucket = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_S3_PREFIX.Switch)) != null) { this.S3Prefix = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_STACK_NAME.Switch)) != null) { this.StackName = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_CLOUDFORMATION_TEMPLATE.Switch)) != null) { this.CloudFormationTemplate = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_STACK_WAIT.Switch)) != null) { this.WaitForStackToComplete = tuple.Item2.BoolValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_CLOUDFORMATION_TEMPLATE_PARAMETER.Switch)) != null) { this.TemplateParameters = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_CLOUDFORMATION_TEMPLATE_SUBSTITUTIONS.Switch)) != null) { this.TemplateSubstitutions = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_CLOUDFORMATION_ROLE.Switch)) != null) { this.CloudFormationRole = tuple.Item2.StringValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_DISABLE_VERSION_CHECK.Switch)) != null) { this.DisableVersionCheck = tuple.Item2.BoolValue; } if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_TAGS.Switch)) != null) { this.Tags = tuple.Item2.KeyValuePairs; } if ((tuple = values.FindCommandOption(CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS.Switch)) != null) { this.MSBuildParameters = tuple.Item2.StringValue; } if (!string.IsNullOrEmpty(values.MSBuildParameters)) { if (this.MSBuildParameters == null) { this.MSBuildParameters = values.MSBuildParameters; } else { this.MSBuildParameters += " " + values.MSBuildParameters; } } }
// This is a positional argument public ValidOptionsAttribute(CommandOptions validOptions) { ValidOptions = validOptions; }
public Task KillAllProcesses(CommandOptions options, CancellationToken cancellationToken, bool logKillCount = false) { return KillAllProcesses(Projects, options, cancellationToken, logKillCount); }
private bool ParseCommandOutput(string Text, HandleOutputDelegate HandleOutput, CommandOptions Options) { if(Options.HasFlag(CommandOptions.NoChannels)) { PerforceOutputLine Line = new PerforceOutputLine(PerforceOutputChannel.Unknown, Text); return HandleOutput(Line); } else if(!IgnoreCommandOutput(Text, Options)) { PerforceOutputLine Line; if(Text.StartsWith("text: ")) { Line = new PerforceOutputLine(PerforceOutputChannel.Text, Text.Substring(6)); } else if(Text.StartsWith("info: ")) { Line = new PerforceOutputLine(PerforceOutputChannel.Info, Text.Substring(6)); } else if(Text.StartsWith("info1: ")) { Line = new PerforceOutputLine(IsValidTag(Text, 7)? PerforceOutputChannel.TaggedInfo : PerforceOutputChannel.Info, Text.Substring(7)); } else if(Text.StartsWith("warning: ")) { Line = new PerforceOutputLine(PerforceOutputChannel.Warning, Text.Substring(9)); } else if(Text.StartsWith("error: ")) { Line = new PerforceOutputLine(PerforceOutputChannel.Error, Text.Substring(7)); } else { Line = new PerforceOutputLine(PerforceOutputChannel.Unknown, Text); } return HandleOutput(Line) && (Line.Channel != PerforceOutputChannel.Error || Options.HasFlag(CommandOptions.NoFailOnErrors)) && Line.Channel != PerforceOutputChannel.Unknown; } return true; }