question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prompt User (ReadLine) if EXE Run Without Command Arguments

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juan-carlos-diazcommented, Oct 5, 2018

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:

    public static void Main(string[] args)
    {
        if(args.Length == 0)
            CommandLineApplication.ExecuteInteractive<Git>();
        else
        {
            // Regular execute call goes here
        }
    }

I create a PR for your consideration #159

0reactions
stale[bot]commented, Apr 9, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found