-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Associated application passes filename only #89
Comments
In 1.5.0.7-commands there is a new option called 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:
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:[email protected]]
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<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!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#89 (comment)> , 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 var fclp = new FluentCommandLineParser();
var result = fclp
.SkipFirstArg()
.Parse(args); Also with |
…st argument. Sometimes this is required when Windows as part of args passed into an application includes the executable name in the first element. This executable name is in most circumstances not required and consumers of FCLP must skip it manually before passing the arguments into the parser.
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?
The text was updated successfully, but these errors were encountered: