From 4bcfbe4d404a3e3fed76a548618ca6d698547ced Mon Sep 17 00:00:00 2001 From: Glenn Condron Date: Fri, 7 Sep 2018 15:21:42 -0700 Subject: [PATCH 1/5] [REPL] Help improvements for repl (#478) * Beginning of help additions. Fixed a nullref. * Standardized help with options displayed as appropriate. --- .../Commands/BaseHttpCommand.cs | 15 +- .../Commands/ChangeDirectoryCommand.cs | 15 +- .../Commands/ConfigCommand.cs | 2 +- .../Commands/EchoCommand.cs | 10 +- .../Commands/ExitCommand.cs | 11 +- .../Commands/HelpCommand.cs | 134 +++++++++++++----- .../Commands/ListCommand.cs | 13 +- .../Commands/PrefCommand.cs | 80 ++++++++++- src/Microsoft.HttpRepl/Commands/RunCommand.cs | 15 +- .../Commands/SetBaseCommand.cs | 8 +- .../Commands/SetHeaderCommand.cs | 16 ++- .../CommandWithStructuredInputBase.cs | 2 +- 12 files changed, 250 insertions(+), 71 deletions(-) diff --git a/src/Microsoft.HttpRepl/Commands/BaseHttpCommand.cs b/src/Microsoft.HttpRepl/Commands/BaseHttpCommand.cs index 9a5eba8..a8ad52f 100644 --- a/src/Microsoft.HttpRepl/Commands/BaseHttpCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/BaseHttpCommand.cs @@ -42,7 +42,7 @@ namespace Microsoft.HttpRepl.Commands protected abstract bool RequiresBody { get; } - protected override CommandInputSpecification InputSpec + public override CommandInputSpecification InputSpec { get { @@ -469,7 +469,18 @@ namespace Microsoft.HttpRepl.Commands protected override string GetHelpDetails(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { - return $"Issues a {Verb.ToUpperInvariant()} request"; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine($"{Verb.ToUpperInvariant()} [Options]"); + helpText.AppendLine(); + helpText.AppendLine($"Issues a {Verb.ToUpperInvariant()} request."); + + if (RequiresBody) + { + helpText.AppendLine("Your default editor will be opened with a sample body if no options are provided."); + } + + return helpText.ToString(); } public override string GetHelpSummary(IShellState shellState, HttpState programState) diff --git a/src/Microsoft.HttpRepl/Commands/ChangeDirectoryCommand.cs b/src/Microsoft.HttpRepl/Commands/ChangeDirectoryCommand.cs index a18aa2d..4fd011d 100644 --- a/src/Microsoft.HttpRepl/Commands/ChangeDirectoryCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/ChangeDirectoryCommand.cs @@ -4,11 +4,13 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.HttpRepl.Suggestions; using Microsoft.Repl; using Microsoft.Repl.Commanding; +using Microsoft.Repl.ConsoleHandling; using Microsoft.Repl.Parsing; namespace Microsoft.HttpRepl.Commands @@ -60,18 +62,19 @@ namespace Microsoft.HttpRepl.Commands return Task.CompletedTask; } - protected override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("cd") + public override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("cd") .MaximumArgCount(1) .Finish(); protected override string GetHelpDetails(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { - if (commandInput.Arguments.Count == 1 && !string.IsNullOrEmpty(commandInput.Arguments[0]?.Text)) - { - return "Prints the current directory if no argument is specified, otherwise changes to the specified directory"; - } + var help = new StringBuilder(); + help.Append("Usage:".Bold()); + help.AppendLine("cd [directory]"); + help.AppendLine(); + help.AppendLine("Prints the current directory if no argument is specified, otherwise changes to the specified directory"); - return "Changes to the directory " + commandInput.Arguments[0].Text; + return help.ToString(); } public override string GetHelpSummary(IShellState shellState, HttpState programState) diff --git a/src/Microsoft.HttpRepl/Commands/ConfigCommand.cs b/src/Microsoft.HttpRepl/Commands/ConfigCommand.cs index 9389363..9ad71ea 100644 --- a/src/Microsoft.HttpRepl/Commands/ConfigCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/ConfigCommand.cs @@ -55,7 +55,7 @@ namespace Microsoft.HttpRepl.Commands } } - protected override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("config").Finish(); + public override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("config").Finish(); protected override string GetHelpDetails(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { diff --git a/src/Microsoft.HttpRepl/Commands/EchoCommand.cs b/src/Microsoft.HttpRepl/Commands/EchoCommand.cs index e81ff81..e4c0ace 100644 --- a/src/Microsoft.HttpRepl/Commands/EchoCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/EchoCommand.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Repl; @@ -37,11 +38,16 @@ namespace Microsoft.HttpRepl.Commands return Task.CompletedTask; } - protected override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("echo").ExactArgCount(1).Finish(); + public override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("echo").ExactArgCount(1).Finish(); protected override string GetHelpDetails(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { - return "Turns request echoing on or off"; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine($"echo [on|off]"); + helpText.AppendLine(); + helpText.AppendLine($"Turns request echoing on or off. When request echoing is on we will display a text representation of requests made by the CLI."); + return helpText.ToString(); } public override string GetHelpSummary(IShellState shellState, HttpState programState) diff --git a/src/Microsoft.HttpRepl/Commands/ExitCommand.cs b/src/Microsoft.HttpRepl/Commands/ExitCommand.cs index af76ad9..ea6bf74 100644 --- a/src/Microsoft.HttpRepl/Commands/ExitCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/ExitCommand.cs @@ -1,10 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Repl; using Microsoft.Repl.Commanding; +using Microsoft.Repl.ConsoleHandling; using Microsoft.Repl.Parsing; namespace Microsoft.HttpRepl.Commands @@ -17,11 +19,16 @@ namespace Microsoft.HttpRepl.Commands return Task.CompletedTask; } - protected override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("exit").ExactArgCount(0).Finish(); + public override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("exit").ExactArgCount(0).Finish(); protected override string GetHelpDetails(IShellState shellState, object programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { - return "Exits the shell"; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine($"exit"); + helpText.AppendLine(); + helpText.AppendLine($"Exits the shell"); + return helpText.ToString(); } public override string GetHelpSummary(IShellState shellState, object programState) diff --git a/src/Microsoft.HttpRepl/Commands/HelpCommand.cs b/src/Microsoft.HttpRepl/Commands/HelpCommand.cs index 6677bde..26e4468 100644 --- a/src/Microsoft.HttpRepl/Commands/HelpCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/HelpCommand.cs @@ -10,6 +10,7 @@ using Microsoft.HttpRepl.Preferences; using Microsoft.HttpRepl.Suggestions; using Microsoft.Repl; using Microsoft.Repl.Commanding; +using Microsoft.Repl.ConsoleHandling; using Microsoft.Repl.Parsing; namespace Microsoft.HttpRepl.Commands @@ -46,7 +47,30 @@ namespace Microsoft.HttpRepl.Commands if (!string.IsNullOrEmpty(help)) { anyHelp = true; + shellState.ConsoleManager.WriteLine(); shellState.ConsoleManager.WriteLine(help); + + var structuredCommand = command as CommandWithStructuredInputBase; + if (structuredCommand != null && structuredCommand.InputSpec.Options.Any()) + { + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine("Options:".Bold()); + foreach (var option in structuredCommand.InputSpec.Options) + { + var optionText = string.Empty; + foreach (var form in option.Forms) + { + if (!string.IsNullOrEmpty(optionText)) + { + optionText += "|"; + } + optionText += form; + } + shellState.ConsoleManager.WriteLine($" {optionText}"); + } + } + + break; } } } @@ -67,39 +91,42 @@ namespace Microsoft.HttpRepl.Commands } } - IDirectoryStructure structure = programState.Structure.TraverseTo(parseResult.Sections[1]); - if (structure.DirectoryNames.Any()) + //Structure is null because, for example, SwaggerEndpoint exists but is not reachable. + if (programState.Structure != null) { - shellState.ConsoleManager.WriteLine("Child directories:"); - - foreach (string name in structure.DirectoryNames) + IDirectoryStructure structure = programState.Structure.TraverseTo(parseResult.Sections[1]); + if (structure.DirectoryNames.Any()) { - shellState.ConsoleManager.WriteLine(" " + name + "/"); + shellState.ConsoleManager.WriteLine("Child directories:"); + + foreach (string name in structure.DirectoryNames) + { + shellState.ConsoleManager.WriteLine(" " + name + "/"); + } + anyHelp = true; } - anyHelp = true; - } - - if (structure.RequestInfo != null) - { - if (structure.RequestInfo.Methods.Count > 0) + if (structure.RequestInfo != null) { - if (anyHelp) + if (structure.RequestInfo.Methods.Count > 0) { - shellState.ConsoleManager.WriteLine(); - } - - anyHelp = true; - shellState.ConsoleManager.WriteLine("Available methods:"); - - foreach (string method in structure.RequestInfo.Methods) - { - shellState.ConsoleManager.WriteLine(" " + method.ToUpperInvariant()); - IReadOnlyList accepts = structure.RequestInfo.ContentTypesByMethod[method]; - string acceptsString = string.Join(", ", accepts.Where(x => !string.IsNullOrEmpty(x))); - if (!string.IsNullOrEmpty(acceptsString)) + if (anyHelp) { - shellState.ConsoleManager.WriteLine(" Accepts: " + acceptsString); + shellState.ConsoleManager.WriteLine(); + } + + anyHelp = true; + shellState.ConsoleManager.WriteLine("Available methods:"); + + foreach (string method in structure.RequestInfo.Methods) + { + shellState.ConsoleManager.WriteLine(" " + method.ToUpperInvariant()); + IReadOnlyList accepts = structure.RequestInfo.ContentTypesByMethod[method]; + string acceptsString = string.Join(", ", accepts.Where(x => !string.IsNullOrEmpty(x))); + if (!string.IsNullOrEmpty(acceptsString)) + { + shellState.ConsoleManager.WriteLine(" Accepts: " + acceptsString); + } } } } @@ -176,15 +203,54 @@ namespace Microsoft.HttpRepl.Commands public void CoreGetHelp(IShellState shellState, ICommandDispatcher dispatcher, HttpState programState) { - foreach (ICommand command in dispatcher.Commands) - { - string help = command.GetHelpSummary(shellState, programState); + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine("HTTP Commands:".Bold().Cyan()); + shellState.ConsoleManager.WriteLine("Use these commands to execute requests against your application."); + shellState.ConsoleManager.WriteLine(); - if (!string.IsNullOrEmpty(help)) - { - shellState.ConsoleManager.WriteLine(help); - } - } + const int navCommandColumn = -15; + + shellState.ConsoleManager.WriteLine($"{"GET",navCommandColumn}{"Issues a GET request."}"); + shellState.ConsoleManager.WriteLine($"{"POST",navCommandColumn}{"Issues a POST request."}"); + shellState.ConsoleManager.WriteLine($"{"PUT",navCommandColumn}{"Issues a PUT request."}"); + shellState.ConsoleManager.WriteLine($"{"DELETE",navCommandColumn}{"Issues a DELETE request."}"); + shellState.ConsoleManager.WriteLine($"{"PATCH",navCommandColumn}{"Issues a PATCH request."}"); + shellState.ConsoleManager.WriteLine($"{"HEAD",navCommandColumn}{"Issues a HEAD request."}"); + shellState.ConsoleManager.WriteLine($"{"OPTIONS",navCommandColumn}{"Issues an OPTIONS request."}"); + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine($"{"set header",navCommandColumn}{"Sets or clears a header for all requests. e.g. `set header content-type:application/json`"}"); + shellState.ConsoleManager.WriteLine(); + + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine("Navigation Commands:".Bold().Cyan()); + shellState.ConsoleManager.WriteLine("The REPL allows you to navigate your URL space and focus on specific APIS that you are working on."); + shellState.ConsoleManager.WriteLine(); + + shellState.ConsoleManager.WriteLine($"{"set base",navCommandColumn}{"Set the base URI. e.g. `set base http://locahost:5000`"}"); + shellState.ConsoleManager.WriteLine($"{"set swagger",navCommandColumn}{"Set the URI, relative to your base if set, of the Swagger document for this API. e.g. `set swagger /swagger/v1/swagger.json`"}"); + shellState.ConsoleManager.WriteLine($"{"ls",navCommandColumn}{"Show all endpoints for the current path."}"); + shellState.ConsoleManager.WriteLine($"{"cd",navCommandColumn}{"Append the given directory to the currently selected path, or move up a path when using `cd ..`."}"); + + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine("Shell Commands:".Bold().Cyan()); + shellState.ConsoleManager.WriteLine("Use these commands to interact with the REPL shell."); + shellState.ConsoleManager.WriteLine(); + + shellState.ConsoleManager.WriteLine($"{"clear",navCommandColumn}{"Removes all text from the shell."}"); + shellState.ConsoleManager.WriteLine($"{"echo [on/off]",navCommandColumn}{"Turns request echoing on or off, show the request that was mode when using request commands."}"); + shellState.ConsoleManager.WriteLine($"{"exit",navCommandColumn}{"Exit the shell."}"); + + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine("REPL Customization Commands:".Bold().Cyan()); + shellState.ConsoleManager.WriteLine("Use these commands to customize the REPL behavior.."); + shellState.ConsoleManager.WriteLine(); + + shellState.ConsoleManager.WriteLine($"{"pref [get/set]",navCommandColumn}{"Allows viewing or changing preferences, e.g. 'pref set editor.command.default 'C:\\Program Files\\Microsoft VS Code\\Code.exe'`"}"); + shellState.ConsoleManager.WriteLine($"{"run",navCommandColumn}{"Runs the script at the given path. A script is a set of commands that can be typed with one command per line."}"); + shellState.ConsoleManager.WriteLine($"{"ui",navCommandColumn}{"Displays the swagger UI page, if available, in the default browser."}"); + shellState.ConsoleManager.WriteLine(); + shellState.ConsoleManager.WriteLine("Use help to learn more details about individual commands. e.g. `help get`".Bold().Cyan()); + shellState.ConsoleManager.WriteLine(); } } } diff --git a/src/Microsoft.HttpRepl/Commands/ListCommand.cs b/src/Microsoft.HttpRepl/Commands/ListCommand.cs index b0641f1..ff604e9 100644 --- a/src/Microsoft.HttpRepl/Commands/ListCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/ListCommand.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.HttpRepl.Preferences; using Microsoft.Repl; using Microsoft.Repl.Commanding; +using Microsoft.Repl.ConsoleHandling; using Microsoft.Repl.Parsing; namespace Microsoft.HttpRepl.Commands @@ -118,19 +120,24 @@ namespace Microsoft.HttpRepl.Commands - protected override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("ls").AlternateName("dir") + public override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("ls").AlternateName("dir") .MaximumArgCount(1) .WithOption(new CommandOptionSpecification(RecursiveOption, maximumOccurrences: 1, acceptsValue: true, forms: new[] {"-r", "--recursive"})) .Finish(); protected override string GetHelpDetails(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { - return "Lists the contents of a directory"; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine($"ls [Options]"); + helpText.AppendLine(); + helpText.AppendLine($"Displays the known routes at the current location. Requires a Swagger document to be set."); + return helpText.ToString(); } public override string GetHelpSummary(IShellState shellState, HttpState programState) { - return "ls - Performs a directory listing"; + return "ls - List known routes for the current location"; } protected override IEnumerable GetArgumentSuggestionsForText(IShellState shellState, HttpState programState, ICoreParseResult parseResult, DefaultCommandInput commandInput, string normalCompletionString) diff --git a/src/Microsoft.HttpRepl/Commands/PrefCommand.cs b/src/Microsoft.HttpRepl/Commands/PrefCommand.cs index d4d5d19..02df9ee 100644 --- a/src/Microsoft.HttpRepl/Commands/PrefCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/PrefCommand.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.HttpRepl.Preferences; @@ -42,19 +43,86 @@ namespace Microsoft.HttpRepl.Commands protected override string GetHelpDetails(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult) { + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + if (commandInput.Arguments.Count == 0 || !_allowedSubcommands.Contains(commandInput.Arguments[0]?.Text)) { - return "pref [get/set] {setting} [{value}] - Get or sets a preference to a particular value"; + helpText.AppendLine("pref [get/set] {setting} [{value}] - Get or sets a preference to a particular value"); } - - if (string.Equals(commandInput.Arguments[0].Text, "get", StringComparison.OrdinalIgnoreCase)) + else if (string.Equals(commandInput.Arguments[0].Text, "get", StringComparison.OrdinalIgnoreCase)) { - return "pref get [{setting}] - Gets the value of the specified preference or lists all preferences if no preference is specified"; + helpText.AppendLine("pref get [{setting}] - Gets the value of the specified preference or lists all preferences if no preference is specified"); } else { - return "pref set {setting} [{value}] - Sets (or clears if value is not specified) the value of the specified preference"; + helpText.AppendLine("pref set {setting} [{value}] - Sets (or clears if value is not specified) the value of the specified preference"); } + + helpText.AppendLine(); + helpText.AppendLine("Current Default Preferences:"); + foreach (var pref in programState.DefaultPreferences) + { + var val = pref.Value; + if (pref.Key.Contains("colors")) + { + val = GetColor(val); + } + helpText.AppendLine($"{pref.Key,-50}{val}"); + } + helpText.AppendLine(); + helpText.AppendLine("Current Preferences:"); + foreach (var pref in programState.Preferences) + { + var val = pref.Value; + if (pref.Key.Contains("colors")) + { + val = GetColor(val); + } + helpText.AppendLine($"{pref.Key,-50}{val}"); + } + + return helpText.ToString(); + } + + private static string GetColor(string value) + { + if (value.Contains("Bold")) + { + value = value.Bold(); + } + + if (value.Contains("Yellow")) + { + value = value.Yellow(); + } + + if (value.Contains("Cyan")) + { + value = value.Cyan(); + } + + if (value.Contains("Magenta")) + { + value = value.Magenta(); + } + + if (value.Contains("Green")) + { + value = value.Green(); + } + + if (value.Contains("White")) + { + value = value.White(); + } + + if (value.Contains("Black")) + { + value = value.Black(); + } + + return value; } protected override Task ExecuteAsync(IShellState shellState, HttpState programState, DefaultCommandInput commandInput, ICoreParseResult parseResult, CancellationToken cancellationToken) @@ -123,7 +191,7 @@ namespace Microsoft.HttpRepl.Commands return Task.CompletedTask; } - protected override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("pref") + public override CommandInputSpecification InputSpec { get; } = CommandInputSpecification.Create("pref") .MinimumArgCount(1) .MaximumArgCount(3) .Finish(); diff --git a/src/Microsoft.HttpRepl/Commands/RunCommand.cs b/src/Microsoft.HttpRepl/Commands/RunCommand.cs index 3228dbc..09f4649 100644 --- a/src/Microsoft.HttpRepl/Commands/RunCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/RunCommand.cs @@ -4,10 +4,12 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Repl; using Microsoft.Repl.Commanding; +using Microsoft.Repl.ConsoleHandling; using Microsoft.Repl.Parsing; using Microsoft.Repl.Scripting; using Microsoft.Repl.Suggestions; @@ -48,12 +50,13 @@ namespace Microsoft.HttpRepl.Commands { if (parseResult.Sections.Count > 0 && string.Equals(parseResult.Sections[0], Name, StringComparison.OrdinalIgnoreCase)) { - if (parseResult.Sections.Count == 1) - { - return "Runs the specified script"; - } - - return "Runs the script " + parseResult.Sections[1]; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine("run {path to script}"); + helpText.AppendLine(); + helpText.AppendLine("Runs the specified script."); + helpText.AppendLine("A script is a text file containing one CLI command per line. Each line will be run as if it was typed into the CLI."); + return helpText.ToString(); } return null; diff --git a/src/Microsoft.HttpRepl/Commands/SetBaseCommand.cs b/src/Microsoft.HttpRepl/Commands/SetBaseCommand.cs index 76166d5..aa12ec8 100644 --- a/src/Microsoft.HttpRepl/Commands/SetBaseCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/SetBaseCommand.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Sockets; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Repl; @@ -80,7 +81,12 @@ namespace Microsoft.HttpRepl.Commands { if (parseResult.Sections.Count > 1 && string.Equals(parseResult.Sections[0], Name, StringComparison.OrdinalIgnoreCase) && string.Equals(parseResult.Sections[1], SubCommand, StringComparison.OrdinalIgnoreCase)) { - return Description; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine($"set base [uri]"); + helpText.AppendLine(); + helpText.AppendLine(Description); + return helpText.ToString(); } return null; diff --git a/src/Microsoft.HttpRepl/Commands/SetHeaderCommand.cs b/src/Microsoft.HttpRepl/Commands/SetHeaderCommand.cs index 3db62f4..7c46906 100644 --- a/src/Microsoft.HttpRepl/Commands/SetHeaderCommand.cs +++ b/src/Microsoft.HttpRepl/Commands/SetHeaderCommand.cs @@ -4,11 +4,13 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.HttpRepl.Suggestions; using Microsoft.Repl; using Microsoft.Repl.Commanding; +using Microsoft.Repl.ConsoleHandling; using Microsoft.Repl.Parsing; namespace Microsoft.HttpRepl.Commands @@ -18,7 +20,7 @@ namespace Microsoft.HttpRepl.Commands private static readonly string Name = "set"; private static readonly string SubCommand = "header"; - public string Description => "set header {name} [{{value}}] - Sets or clears a header"; + public string Description => "set header {name} [value] - Sets or clears a header"; public bool? CanHandle(IShellState shellState, HttpState programState, ICoreParseResult parseResult) { @@ -43,12 +45,12 @@ namespace Microsoft.HttpRepl.Commands public string GetHelpDetails(IShellState shellState, HttpState programState, ICoreParseResult parseResult) { - if (parseResult.Sections.Count > 1 && string.Equals(parseResult.Sections[0], Name, StringComparison.OrdinalIgnoreCase) && string.Equals(parseResult.Sections[1], SubCommand, StringComparison.OrdinalIgnoreCase)) - { - return Description; - } - - return null; + var helpText = new StringBuilder(); + helpText.Append("Usage: ".Bold()); + helpText.AppendLine("set header {name} [value]"); + helpText.AppendLine(); + helpText.AppendLine("Sets or clears a header. When [value] is empty the header is cleared."); + return Description; } public string GetHelpSummary(IShellState shellState, HttpState programState) diff --git a/src/Microsoft.Repl/Commanding/CommandWithStructuredInputBase.cs b/src/Microsoft.Repl/Commanding/CommandWithStructuredInputBase.cs index a7e07b3..d087d4c 100644 --- a/src/Microsoft.Repl/Commanding/CommandWithStructuredInputBase.cs +++ b/src/Microsoft.Repl/Commanding/CommandWithStructuredInputBase.cs @@ -208,6 +208,6 @@ namespace Microsoft.Repl.Commanding protected abstract Task ExecuteAsync(IShellState shellState, TProgramState programState, DefaultCommandInput commandInput, TParseResult parseResult, CancellationToken cancellationToken); - protected abstract CommandInputSpecification InputSpec { get; } + public abstract CommandInputSpecification InputSpec { get; } } } From e975b87b91a16233e55426ca232d62df4267bd54 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 12:10:33 -0700 Subject: [PATCH 2/5] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 18 +++++++++--------- korebuild-lock.txt | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index fbf093b..4f54bb7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,20 +3,20 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180907.3 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 + 2.2.0-preview1-20180907.8 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 5.2.6 2.0.3 11.0.2 - 4.5.1 + 4.6.0-preview2-26905-02 4.5.0 9.0.1 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index be535d1..552300b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180907.3 -commithash:2315030c7f3de2af0f16cf64502321937b6c4315 +version:2.2.0-preview1-20180907.8 +commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 From 7517263bd4d089680757272dc665d4e94d51950b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 12:09:26 -0700 Subject: [PATCH 3/5] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 12 ++++++------ korebuild-lock.txt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4f54bb7..deb0947 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,12 +3,12 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180907.8 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 + 2.2.0-preview1-20180911.1 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 2.0.9 2.1.3 2.2.0-preview2-26905-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 552300b..1090ad6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180907.8 -commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 +version:2.2.0-preview1-20180911.1 +commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 From 6c39b06a5988e0b17c685024b0ba26cefe6b3208 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 19:11:11 +0000 Subject: [PATCH 4/5] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 12 ++++++------ korebuild-lock.txt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index deb0947..53c1c40 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,12 +3,12 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180911.1 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 + 2.2.0-preview1-20180918.1 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 2.0.9 2.1.3 2.2.0-preview2-26905-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1090ad6..8491de7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180911.1 -commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 +version:2.2.0-preview1-20180918.1 +commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 From c601038484606dab00000ed9bf7581a5659b2215 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Sep 2018 14:24:22 -0700 Subject: [PATCH 5/5] Remove duplicate PackageReferences --- test/Microsoft.Repl.Tests/Microsoft.Repl.Tests.csproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/Microsoft.Repl.Tests/Microsoft.Repl.Tests.csproj b/test/Microsoft.Repl.Tests/Microsoft.Repl.Tests.csproj index 52fbd0d..31a83d8 100644 --- a/test/Microsoft.Repl.Tests/Microsoft.Repl.Tests.csproj +++ b/test/Microsoft.Repl.Tests/Microsoft.Repl.Tests.csproj @@ -2,16 +2,8 @@ netcoreapp2.2 - - false - - - - - -