private static Command ConstructCommand() { var command = new Command("reference", LocalizableStrings.AppFullName); command.AddArgument(ProjectPathArgument); command.AddOption(FrameworkOption); command.Handler = CommandHandler.Create <ParseResult>((parseResult) => new RemoveProjectToProjectReferenceCommand(parseResult).Execute()); return(command); }
private static Command ConstructCommand() { var command = new Command("install", LocalizableStrings.CommandDescription); command.AddArgument(WorkloadIdArgument); AddWorkloadInstallCommandOptions(command); command.Handler = CommandHandler.Create <ParseResult>((parseResult) => new WorkloadInstallCommand(parseResult).Execute()); return(command); }
private void LoadCommanderCommands() { Command serialiseSceneCommand = new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveRegion, "Saves the named region into the exports directory."); serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); Command serialiseAllScenesCommand = new Command("save-all", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveAllRegions, "Saves all regions into the exports directory."); m_commander.RegisterCommand("save", serialiseSceneCommand); m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); }
private static Command ConstructCommand() { var command = new Command("package", LocalizableStrings.AppFullName); command.AddArgument(CmdPackageArgument); command.AddOption(InteractiveOption); command.Handler = CommandHandler.Create <ParseResult>((parseResult) => new RemovePackageReferenceCommand(parseResult).Execute()); return(command); }
public static Command GetCommand() { var command = new Command("internal-reportinstallsuccess") { IsHidden = true }; command.AddArgument(Argument); return(command); }
private static Command ConstructCommand() { var command = new Command("run", LocalizableStrings.CommandDescription); command.AddArgument(CommandNameArgument); command.TreatUnmatchedTokensAsErrors = false; command.Handler = CommandHandler.Create <ParseResult>((parseResult) => new ToolRunCommand(parseResult).Execute()); return(command); }
private static Command ConstructCommand() { Command command = new Command("restore", LocalizableStrings.CommandDescription); command.AddArgument(RestoreCommandParser.SlnOrProjectArgument); WorkloadInstallCommandParser.AddWorkloadInstallCommandOptions(command); command.SetHandler((parseResult) => new WorkloadRestoreCommand(parseResult).Execute()); return(command); }
private Command CreateCommandPrint(Argument dirArgument) { var command = new Command("Print", "Prints contents of a configuration file.") { Handler = GetCommandHandler(nameof(ProcessCommandPrint)), }; command.AddArgument(dirArgument); return(command); }
public static Command BuildCommand() { var cmd = new Command("jql", "Execute JQL and print results"); cmd.AddOption(new Option <string>(new string[] { "--profile", "-p" }, "Profile to use")); cmd.AddOption(new Option <string>(new string[] { "--fields", "-f" }, "Extras fields to get")); cmd.AddOption(new Option <bool>("--export", "Export to csv")); cmd.AddArgument(new Argument <string>("jql")); cmd.Handler = CommandHandler.Create <string, string>(ExecuteJql); return(cmd); }
public static Command GetCommand() { var command = new Command("sln", LocalizableStrings.AppFullName); command.AddArgument(SlnArgument); command.AddCommand(SlnAddParser.GetCommand()); command.AddCommand(SlnListParser.GetCommand()); command.AddCommand(SlnRemoveParser.GetCommand()); return(command); }
public string SendMessage(string message, Player player) { TCPSocketConfiguration.BuildDefaultConfiguration(out TCPSocket tcpSocket); Command sendMessage = new Command("send_message_to_room"); sendMessage.AddArgument("message", message); sendMessage.AddArgument("nickname", player.NickName); sendMessage.AddArgument("user_email", player.Email); sendMessage.AddArgument("room_id", this.IdRoom); tcpSocket.AddCommand(sendMessage); tcpSocket.SendCommand(); string response = tcpSocket.GetResponse(true, 1000); if (response.Equals("OK")) { this.Messages.Add(new KeyValuePair <string, string>(player.NickName, message)); } tcpSocket.Close(); return(response); }
private static void AddBenevisCommand(Command rootCmd) { var logCommand = new Command("benevis", "record a work log"); var fromArg = new Argument <TimeSpan>("from", () => DateTime.Now.TimeOfDay) { Description = "The starting time of the current work log", Arity = ArgumentArity.ExactlyOne }; logCommand.AddArgument(fromArg); var toArg = new Argument <TimeSpan>("to") { Description = "The end time of the current work log", Arity = ArgumentArity.ExactlyOne }; logCommand.AddArgument(toArg); var descriptionArg = new Argument <string>("desc") { Description = "The work log description - Optional", Arity = ArgumentArity.ZeroOrOne }; logCommand.AddArgument(descriptionArg); var detailsArg = new Argument <string>("details") { Description = "The work log details - Optional", Arity = ArgumentArity.ZeroOrOne }; logCommand.AddArgument(detailsArg); logCommand.Handler = CommandHandler.Create <TimeSpan, TimeSpan, string, string>(HandleLogWorkCommand); rootCmd.AddCommand(logCommand); }
public static int[] GetSortedDeck(string idRoom, string email) { TCPSocketConfiguration.BuildDefaultConfiguration(out TCPSocket tcpSocket); Dictionary <string, string> sortedDeck = null; Command getSortedDeck = new Command("get_sorted_deck"); getSortedDeck.AddArgument("player_email", email); getSortedDeck.AddArgument("room_id", idRoom); tcpSocket.AddCommand(getSortedDeck); tcpSocket.SendCommand(); string response = tcpSocket.GetResponse(true, 1000); tcpSocket.Close(); Debug.Log("GetSortedDeck response:" + response); if (!response.Equals("ERROR. TIMEOUT")) { try { Debug.Log(response); sortedDeck = SimpleJson.DeserializeObject <Dictionary <string, string> >(response); } catch (SerializationException) { Debug.Log("Invalid JSON"); sortedDeck = null; } } int[] converted = new int[54]; if (sortedDeck != null) { int i = 0; while (i < 54) { converted[i] = Convert.ToInt32(sortedDeck[i.ToString()]); i++; } } return(converted); }
private static Command ConstructCommand() { var command = new Command("add", LocalizableStrings.AddAppFullName); command.AddArgument(ProjectPathArgument); command.AddOption(InRootOption); command.AddOption(SolutionFolderOption); command.Handler = CommandHandler.Create <ParseResult>((parseResult) => new AddProjectToSolutionCommand(parseResult).Execute()); return(command); }
public Command LoadFile() { Option Skip() { var opt = new Option("--skip", "lines to skip from the file") { Argument = new Argument <int>() }; opt.Argument.SetDefaultValue(0); return(opt); } Option Take() { var opt = new Option("--take", "lines to take from the file") { Argument = new Argument <int>() }; opt.Argument.SetDefaultValue(0); return(opt); } Option Parallel() { var opt = new Option("--parallel", "number of threads to use") { Argument = new Argument <int>() }; opt.Argument.SetDefaultValue(0); return(opt); } var cmd = new Command("load", "Execute queries from files"); cmd.AddOption(ConnectionNameOption()); cmd.AddOption(ConnectionTypeOption()); cmd.AddOption(Skip()); cmd.AddOption(Take()); cmd.AddOption(Parallel()); cmd.AddArgument(QueryFilesArgument()); cmd.Handler = CommandHandler.Create <string, ConnectionType, int, int, int, ParseResult>( async(connectionName, connectionType, skip, take, parallel, parse) => await new ExecuteCommands(_connectionManager, _console).LoadFile( parse.CommandResult.GetArgumentValueOrDefault <FileInfo[]>("queries"), connectionName, connectionType, skip, take, parallel) ); return(cmd); }
private static Command ConstructCommand() { var command = new Command("search", LocalizableStrings.CommandDescription); command.AddArgument(WorkloadIdStubArgument); command.AddOption(VerbosityOption); command.AddOption(VersionOption); command.SetHandler((parseResult) => new WorkloadSearchCommand(parseResult).Execute()); return(command); }
private static Command ConstructCommand() { var command = new Command("reference", LocalizableStrings.AppFullName); command.AddArgument(ProjectPathArgument); command.AddOption(FrameworkOption); command.AddOption(InteractiveOption); command.SetHandler((parseResult) => new AddProjectToProjectReferenceCommand(parseResult).Execute()); return(command); }
public static int Main(string[] args) { var rootCommand = new RootCommand(); var qtCommand = new Command( "--order-templates", description: "Order question templates" ); qtCommand.AddAlias("-ot"); qtCommand.AddArgument(new Argument <string>("question-file")); qtCommand.Handler = CommandHandler.Create <string>((questionFile) => { Console.WriteLine("Ordering question templates"); DbHandler dbHandler = new DbHandler(); dbHandler.OrderQuestionTemplates(questionFile); }); rootCommand.AddCommand(qtCommand); var qfCommand = new Command( "--templates", description: "JSON-file with questions" ); qfCommand.AddAlias("-t"); qfCommand.AddArgument(new Argument <string>("question-file")); qfCommand.Handler = CommandHandler.Create <string>((questionFile) => { Console.WriteLine($"The given input is: {questionFile}"); DbHandler dbHandler = new DbHandler(); dbHandler.PopulateQuestionTemplate(questionFile); }); rootCommand.AddCommand(qfCommand); var oqCommand = new Command( "--order-questions", description: "Order questions in given evaluation" ); oqCommand.AddAlias("-oq"); oqCommand.AddArgument(new Argument <string>("evaluation-id")); oqCommand.Handler = CommandHandler.Create <string>((evaluationId) => { Console.WriteLine($"Ordering questions for evaluation: {evaluationId}"); DbHandler dbHandler = new DbHandler(); dbHandler.OrderQuestionsInEvaluation(evaluationId); }); rootCommand.AddCommand(oqCommand); rootCommand.Description = "Various scripts for DB handling"; return(rootCommand.InvokeAsync(args).Result); }
public static Command GetCommand() { var command = new Command("complete") { IsHidden = true }; command.AddArgument(PathArgument); command.AddOption(PositionOption); return(command); }
public Command GetCommand() { var notes = new Command("notes", "Opens the notes directory and creates a new note for today if it doesn't exist.") { new Option <bool>(new string[] { "--nocreate", "-n" }, "Do not create today's note."), new Option <bool>(new string[] { "--configure", "-c" }, "Set the notes directory.") }; notes.AddArgument(new Argument <string>("filename", () => DateTime.Now.ToString("yyyy-MM-dd"))); notes.Handler = CommandHandler.Create(async(bool nocreate, bool configure, string filename) => await OpenNotes(nocreate, configure, filename)); return(notes); }
static private Command DownloadCmd() { var cmd = new Command("download") { Description = "Download recorded data. This command may require prior device restart.", Handler = CommandHandler.Create <string, OutputFormat>(CMS50DPlus.Download), }; cmd.AddOption(new Option <OutputFormat>("--format", () => OutputFormat.NdJson, "Output format")); cmd.AddArgument(new Argument <string>("devicePath")); return(cmd); }
static private Command StreamCmd() { var cmd = new Command("stream") { Description = "Stream live data to stdout", Handler = CommandHandler.Create <string, OutputFormat>(CMS50DPlus.Stream), }; cmd.AddOption(new Option <OutputFormat>("--format", () => OutputFormat.NdJson, "Output format")); cmd.AddArgument(new Argument <string>("devicePath")); return(cmd); }
public static Command GetCommand() { var command = new Command("uninstall", LocalizableStrings.CommandDescription); command.AddArgument(PackageIdArgument); command.AddOption(GlobalOption); command.AddOption(LocalOption); command.AddOption(ToolPathOption); command.AddOption(ToolManifestOption); return(command); }
public static Command Create(HttpClient httpClient) { var command = new Command( name: "add-url", description: CoreStrings.AddUrlCommandDescription); var projectOption = CommonOptions.ProjectOption(); var serviceOption = CommonOptions.ServiceOption(); var additionalImportDirsOption = CommonOptions.AdditionalImportDirsOption(); var accessOption = CommonOptions.AccessOption(); var outputOption = new Option <string>( aliases: new[] { "-o", "--output" }, description: CoreStrings.OutputOptionDescription); var urlArgument = new Argument <string> { Name = "url", Description = CoreStrings.AddUrlCommandArgumentDescription, Arity = ArgumentArity.ExactlyOne }; command.AddOption(outputOption); command.AddOption(projectOption); command.AddOption(serviceOption); command.AddOption(additionalImportDirsOption); command.AddOption(accessOption); command.AddArgument(urlArgument); command.SetHandler <string, Services, Access, string?, string, string, InvocationContext, IConsole>( async(project, services, access, additionalImportDirs, url, output, context, console) => { try { if (string.IsNullOrEmpty(output)) { throw new CLIToolException(CoreStrings.ErrorNoOutputProvided); } var command = new AddUrlCommand(console, project, httpClient); await command.AddUrlAsync(services, access, additionalImportDirs, url, output); context.ExitCode = 0; } catch (CLIToolException e) { console.LogError(e); context.ExitCode = -1; } }, projectOption, serviceOption, accessOption, additionalImportDirsOption, urlArgument, outputOption); return(command); }
public static Command GetCommand() { var command = new Command("restore", LocalizableStrings.AppFullName); command.AddArgument(SlnOrProjectArgument); foreach (var option in FullRestoreOptions()) { command.AddOption(option); } return(command); }
private static Command ConstructCommand() { var command = new Command("internal-reportinstallsuccess") { IsHidden = true }; command.AddArgument(Argument); command.SetHandler(InternalReportinstallsuccess.Run); return(command); }
public static Command BuildCommand() { var command = new Command("component-outline", "Output a JSON component outline."); var input = new Argument("input"); input.Description = "Path to component."; input.Arity = ArgumentArity.ExactlyOne; command.AddArgument(input); command.Handler = CommandHandler.Create <IHost, Options>(Run); return(command); }
public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory) { var command = new Command("show", "Show information about a package"); AddCommonOptions(command); command.AddArgument(new Argument <string>("package", null)); command.Handler = CommandHandler.Create <ShowArguments>(async args => { await new ShowCommand(renderer, config, controllerFactory, args).ExecuteAsync(args); }); return(command); }
public async Task Method_parameters_on_the_invoked_method_are_bound_to_matching_argument_names_with_pipe_in() { string boundName = default; int boundAge = default; void Execute(string fullnameOrNickname, int age) { boundName = fullnameOrNickname; boundAge = age; } var command = new Command("command"); command.AddArgument(new Argument <int>("age")); command.AddArgument(new Argument <string>("fullname|nickname")); command.Handler = CommandHandler.Create <string, int>(Execute); await command.InvokeAsync("command 425 Gandalf", _console); boundName.Should().Be("Gandalf"); boundAge.Should().Be(425); }
public async Task Method_parameters_on_the_invoked_method_can_be_bound_to_argument_names_case_insensitively() { string boundName = default; int boundAge = default; void Execute(string name, int AGE) { boundName = name; boundAge = AGE; } var command = new Command("command"); command.AddArgument(new Argument <int>("AGE")); command.AddArgument(new Argument <string>("Name")); command.Handler = CommandHandler.Create <string, int>(Execute); await command.InvokeAsync("command 425 Gandalf", _console); boundName.Should().Be("Gandalf"); boundAge.Should().Be(425); }