Open genfail opened 6 years ago
In 1.5.0.7-commands there is a new option called UseForOrphanArguments
, you use it like this:
var fclp = new FluentCommandLineParser<Args>();
fclp.Setup(arg => arg.File)
.As('f', "file")
.UseForOrphanArguments(); // if no option specified then values are bound to this option
which means your use case will now be much friendlier to handle:
app.exe "c:\my folder\datafile.dat"
will result in fclp.Object.File == "c:\\my folder\datafile.dat"
super!
Hi Siy,
Thank you for this nice extension. Exactly what I needed,
But in Environment.GetCommandLineArgs() the 1st argument is always the complete path of the current exe, so while parsing you should ignore the 1st element (or at least make an option to ignore the first argument). Currently I use:
args = args.Skip(1).ToArray();
Marcel
From: Siy Williams [mailto:notifications@github.com] Sent: zaterdag 25 november 2017 22:23 To: fclp/fluent-command-line-parser Cc: genfail; Author Subject: Re: [fclp/fluent-command-line-parser] Associated application passes filename only (#89)
In 1.5.0.7-commands https://www.nuget.org/packages/FluentCommandLineParser/1.5.0.7-commands there is a new option called UseForOrphanArguments, you use it like this:
var fclp = new FluentCommandLineParser
fclp.Setup(arg => arg.File) .As('f', "file") .UseForOrphanArguments(); // if no option specified then values are bound to this option
which means your use case will now be much friendlier to handle:
app.exe "c:\my folder\datafile.dat" will result in fclp.Object.File == "c:\my folder\datafile.dat"
super!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fclp/fluent-command-line-parser/issues/89#issuecomment-346967112 , or mute the thread https://github.com/notifications/unsubscribe-auth/AK5KE4WBrSd0UMlnIOI1xgTskBCLFYOBks5s6IVIgaJpZM4QGpBO . https://github.com/notifications/beacon/AK5KE1hDf1yINFXPk3P_0dOKVMVzQMCCks5s6IVIgaJpZM4QGpBO.gif
Deze e-mail is gecontroleerd op virussen door AVG. http://www.avg.com
I've had a good think about this, my initial thought was that I don't want to bend FCLP to fit the nuances of the different ways .NET serves up the command line args, or how windows serves them into the app itself.
However its a small mod and not the first time someone has raised it so I think adding a SkipFirstArg()
option that can be used in the following would work nicely:
var fclp = new FluentCommandLineParser();
var result = fclp
.SkipFirstArg()
.Parse(args);
Also with SkipFirstArg()
being right next to the Parse(string[])
method it is really explicit.
when i create an app.exe that can handle data files, i ca nassociate the extension to my app. When doubleclicking in the explorer on a data file, windows starts my associated application by: c":\prog files\app.exe" "c:\my folder\datafile.dat" So the commandline will have an argument without any -f or other character. How can I handle that?