Skip to content
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

Merged
merged 8 commits into from
Feb 9, 2019
Merged

Args replacement for Argu #303

merged 8 commits into from
Feb 9, 2019

Conversation

AnthonyLloyd
Copy link
Contributor

No description provided.

@haf
Copy link
Owner

haf commented Feb 4, 2019

Hmm, needs review? Did you just build a parser ;)

@AnthonyLloyd AnthonyLloyd changed the title Args replacement for Argu [WIP] Args replacement for Argu Feb 4, 2019
@AnthonyLloyd
Copy link
Contributor Author

Still v rough and I haven't tested it yet.

@haf
Copy link
Owner

haf commented Feb 4, 2019

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.

@AnthonyLloyd AnthonyLloyd changed the title [WIP] Args replacement for Argu Args replacement for Argu Feb 5, 2019
@AnthonyLloyd
Copy link
Contributor Author

@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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider sequence equal

Copy link
Contributor Author

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 Show resolved Hide resolved
Expecto/Expecto.fs Outdated Show resolved Hide resolved
Expecto/Expecto.fs Outdated Show resolved Hide resolved
Expecto/Expecto.fs Outdated Show resolved Hide resolved
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)
Copy link
Owner

@haf haf Feb 6, 2019

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

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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.

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.

Expecto/Expecto.fs Outdated Show resolved Hide resolved
@haf
Copy link
Owner

haf commented Feb 6, 2019

Looking good

@AnthonyLloyd AnthonyLloyd merged commit f2b2583 into master Feb 9, 2019
@haf haf deleted the args branch February 9, 2019 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants