CLI: Prompt directy for HttpMethod, ignore input when exiting log
This commit is contained in:
parent
3365be219c
commit
f4bc182954
@ -79,17 +79,15 @@ internal sealed class TrangaCli : Command<TrangaCli.Settings>
|
|||||||
switch (menuSelect)
|
switch (menuSelect)
|
||||||
{
|
{
|
||||||
case "CustomRequest":
|
case "CustomRequest":
|
||||||
string requestType = AnsiConsole.Prompt(
|
HttpMethod requestMethod = AnsiConsole.Prompt(
|
||||||
new SelectionPrompt<string>()
|
new SelectionPrompt<HttpMethod>()
|
||||||
.Title("Request Type")
|
.Title("Request Type")
|
||||||
.AddChoices(new[]
|
.AddChoices(new[]
|
||||||
{
|
{
|
||||||
"GET",
|
HttpMethod.Get,
|
||||||
"POST",
|
HttpMethod.Delete,
|
||||||
"DELETE"
|
HttpMethod.Post
|
||||||
}));
|
}));
|
||||||
HttpMethod method = requestType == "GET" ? HttpMethod.Get :
|
|
||||||
requestType == "DELETE" ? HttpMethod.Delete : HttpMethod.Post;
|
|
||||||
string requestPath = AnsiConsole.Prompt(
|
string requestPath = AnsiConsole.Prompt(
|
||||||
new TextPrompt<string>("Request Path:"));
|
new TextPrompt<string>("Request Path:"));
|
||||||
List<ValueTuple<string, string>> parameters = new();
|
List<ValueTuple<string, string>> parameters = new();
|
||||||
@ -108,7 +106,7 @@ internal sealed class TrangaCli : Command<TrangaCli.Settings>
|
|||||||
requestString += $"{parameter.Item1}={parameter.Item2}&";
|
requestString += $"{parameter.Item1}={parameter.Item2}&";
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequestMessage request = new HttpRequestMessage(method, requestString);
|
HttpRequestMessage request = new (requestMethod, requestString);
|
||||||
AnsiConsole.WriteLine($"Request: {request.Method} {request.RequestUri}");
|
AnsiConsole.WriteLine($"Request: {request.Method} {request.RequestUri}");
|
||||||
HttpResponseMessage response;
|
HttpResponseMessage response;
|
||||||
if (AnsiConsole.Confirm("Send Request?"))
|
if (AnsiConsole.Confirm("Send Request?"))
|
||||||
@ -133,8 +131,11 @@ internal sealed class TrangaCli : Command<TrangaCli.Settings>
|
|||||||
context.UpdateTarget(rows);
|
context.UpdateTarget(rows);
|
||||||
}
|
}
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
if (Console.KeyAvailable)
|
if (AnsiConsole.Console.Input.IsKeyAvailable())
|
||||||
|
{
|
||||||
|
AnsiConsole.Console.Input.ReadKey(true); //Do not process input
|
||||||
running = false;
|
running = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user