Prompt User (ReadLine) if EXE Run Without Command Arguments
See original GitHub issueI have a basic subcommand
structure App.
What I want is if the executable is run without parameters, I want the App to essentially ReadLine
and allow the user to input the commands.
Is this possible with a flag perhaps?
See below for my basic App structure:
public static int Main(string[] args)
{
var app = new CommandLineApplication();
app.HelpOption(inherited: true);
// Invite User
app.Command("invite", inviteUserCmd =>
{
var tenantName = inviteUserCmd.Argument("username", "Users name.").IsRequired();
inviteUserCmd.OnExecute(async () =>
{
// do work here
});
});
// register user
app.Command("register", registerUserCmd =>
{
registerUserCmd.OnExecute(async () =>
{
// do work here
});
});
app.OnExecute(() =>
{
Console.WriteLine("Specify a command");
app.ShowHelp();
return 1;
});
return app.Execute(args);
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How to get a user input in command prompt and pass it to R
Use readLines (con = "stdin", n = 1) to read user input from the terminal. Use commandArgs(trailingOnly = TRUE) to supply the input...
Read more >Console.ReadLine Method (System)
One of the most common uses of the ReadLine method is to pause program execution before clearing the console and displaying new information...
Read more >Prevent cmd window from closing when it's run
It is not possible to configure cmd to always remain open when launching an exe file that runs through console.
Read more >User input with Java's Console class
The readLine() method takes user input through the console window, stores the input data in a String, and echoes the input back to...
Read more >Readline | Node.js v20.5.1 Documentation
The output stream is used to print prompts for user input that arrives on, and is read ... The listener function is called...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey Nate, I just implement something I call “interactive session” where you get into a loop collecting and executing commands and this can be used in case no args are pass to the app, like this:
I create a PR for your consideration #159
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 7 days.