You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After tonight's meeting here is one possible approach.
Change dragonfriut to find all public and internal methods inside of Program. In addition, include methods on nested classes as well.
If there is only a single method that is found and its name if "Main", simply configure the implicit root command with the options from the method. Simply invoke ConfigureFromMethod on the builder without adding any commands.
If multiple method are found, add each to the builder as a command. The name of the command should be the method name. If the method is inside of a nested class add the nested class as a parent command using the class name as the command name.
Another option to consider would be using Dragonfruit as the entry point for Starfruit. In other words, the app programmer could write a class such as:
class Program
{
public static void Main( MyCommandLine commandLine )
}
class MyCommandLine
{
string Arg1 { get; set ; }
bool Switch1 { get; set; }
int Count1 { get; set }
SubCommand { get; set}
}
class SubCommand
{
string Arg2 { get; set; }
}
I love the idea of having public static methods in Program become subcommands. I'll often move the top-level methods into Program.Command1.cs and Program.Command2.cs.
So... I don't know how kosher this is, but there are a couple instances where we went with this format:
publicstaticclassProgram{publicstaticasyncTask<int>Main(string[]args){// Manually maintained code at the moment.// Makes calls like: await Foo(...).InnerCommand(...).ConfigureAwait(false);}publicstaticFooCommandFoo(stringopt1,stringopt2,stringopt3){returnnewFooCommand(opt1,opt2,opt3);}publicreadonlystructFooCommand{privatereadonlystringopt1;privatereadonlystringopt2;privatereadonlystringopt3;publicFooCommand(stringopt1,stringopt2,stringopt3){this.opt1=opt1;this.opt2=opt2;this.opt3=opt3;}publicasyncTaskInnerCommand(stringopt4,stringopt5){// Do stuff with opt1, opt2, opt3, opt4, and opt5}publicasyncTaskInnerCommand2(stringopt6,stringopt7,stringopt8){// Do stuff with opt1, opt2, opt3, opt6, opt7, and opt8}}publicstaticasyncTaskBar(stringopt1,stringopt2,stringopt9){// Do stuff with opt1, opt2, and opt9}}
(Made everything string for clarity. In actuality there were arguments such as IReadOnlyList<string> files and bool loseWork = false.)
Activity
Keboo commentedon Jun 6, 2018
After tonight's meeting here is one possible approach.
public
andinternal
methods inside ofProgram
. In addition, include methods on nested classes as well.ConfigureFromMethod
on the builder without adding any commands.Example with simple commands.
Allows invocations:
Example with nested commands:
Allows invocation
MarkMichaelis commentedon Jun 8, 2018
Another option to consider would be using Dragonfruit as the entry point for Starfruit. In other words, the app programmer could write a class such as:
jonsequitur commentedon Nov 9, 2018
Related: #297
jnm2 commentedon Dec 21, 2018
I love the idea of having public static methods in
Program
become subcommands. I'll often move the top-level methods intoProgram.Command1.cs
andProgram.Command2.cs
.So... I don't know how kosher this is, but there are a couple instances where we went with this format:
<command> <opt1> <opt2> <opt3> <inner command> <opt4> <opt5>
<command> <opt1> <opt2> <opt3> <inner command 2> <opt6> <opt7> <opt8>
<command 2> <opt1> <opt2> <opt9>
And so we modeled this as:
(Made everything
string
for clarity. In actuality there were arguments such asIReadOnlyList<string> files
andbool loseWork = false
.)Does this seem like a good model to recognize?
Cyber1000 commentedon Feb 19, 2023
Any news on this? Sorry to answer an old thread, but it seems to be still open.
Thanks!
KathleenDollard commentedon Feb 21, 2023
We still plan a generation based simplifying approach that will include subcommands. When the spec is further along we will post it.
vonj commentedon Mar 14, 2023
Can't wait!