Closed asheesh1996 closed 2 years ago
Hi @asheesh1996 the documentation has fallen behind a bit and I've been working to update it. I just merged a branch to master with updated Getting Started docs that should work for you. Let me know if there are still problems.
@asheesh1996 has the updated documentation been helpful? Are you still having problems?
Hi @drewburlingame , I tried the updated documentation, following is the code snippet
using CommandDotNet;
namespace CommandLineTest
{
public class Program
{
// this is the entry point of your application
static int Main(string[] args)
{
// AppRunner<T> where T is the class defining your commands
var OP = new AppRunner<Program>().Run(args);
Console.WriteLine(OP.ToString());
return OP;
}
// Add command with two positional arguments
public void Add(int x, int y) => Console.WriteLine(x + y);
// Subtract command with two positional arguments
public void Subtract(int x, int y) => Console.WriteLine(x - y);
}
}
And application is closing with following output
Usage: CommandLineTest.exe [command]
Commands:
Add
Subtract
Use "CommandLineTest.exe [command] --help" for more information about a command.
1
D:\Development\CommandLineTest\CommandLineTest\bin\Debug\net6.0\CommandLineTest.exe (process 19532) exited with code 1.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
How are you executing the app? If you're not passing in a command to run or a help option, this is the expected behavior because CommandDotNet is not able to execute a command since there's no default command and no subcommand was specified. It prints the help as a courtesy. If you typed in CommandLineTest.exe -h
or CommandLineTest.exe --help
then you'd get the same output but OP would be 0. If you typed CommandLineTest.exe Add 1 1
then it should print 2 and OP would be 0.
What I'll do is follow the convention used by the dotnet
tool and print Required command was not provided.
when this happens, and then the help text.
This will go out with our next release.
I've pushed 6.0.1. I'll close this for now. Reopen if the cause is different than what I've stated above.
Thanks for the response, I was using it in the wrong way. I got it working .
Good to hear you got it working. Feel free to start up a discussion of you have questions or challenges.
following code snippet in dotnet 6 is giving error and closing the console app