-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Args replacement for Argu #303
Conversation
Hmm, needs review? Did you just build a parser ;) |
Still v rough and I haven't tested it yet. |
There's a MIT-licensed single-fs-file parser that I financed/own over here https://github.com/logibit/EmParsec/blob/master/EmParsec.fs — that you can paste into this code-base if you want. It's been through a couple of thousands of strings, so it should do the trick; it doesn't reify values to arguments though, like you're doing. |
@haf now fully functional as far as I can see. |
@@ -181,6 +181,9 @@ let tests = | |||
|
|||
[<Tests>] | |||
let expecto = | |||
|
|||
let testArgs i o = Expect.equal (Args.parseOptions options i) o "testArgs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider sequence equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's comparing a Result<args list,string list>
so a bit more tricky.
Expecto/Expecto.fs
Outdated
collect help | ||
(updateUnknown unknown (i+paramCount) unknownCount) | ||
(Result.mapError (fun i -> option + " " + i) arg::args) 0 (i-1) | ||
| None -> collect help unknown args (paramCount+1) (i-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A future PR could do fuzzy matching of input flag names here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes a bit like powershell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haf How would that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Powershell lets you shorten switches as long as they are unambiguous. This actually may not be a good idea for back compact reasons when new switches are added.
A possibly more useful one would be to suggest the correct switch based on a distance measure. Worth considering in the future. If there are enough good ideas I may pull Args out as a single file Args utility. Personally keen on where this could go as I use these quite a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I think the PowerShell folks got it wrong and they are starting to realize it. With PowerShell 6, a group in Microsoft was looking into Query Auto Completion-like features to predict what you want to type for a command. Sort of like next-gen IntelliSense for the command line. https://microsoft.github.io/prose/ Microsoft Program Synthesis using Examples SDK
Can you share how you use it a lot?
Simplest way to share would be to create a PowerShell Profile with a History logger extension so that you can record what you do in each session. Then you can really data mine your use cases.
Looking good |
No description provided.