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

Reliable argument handling #76

Open
Stebalien opened this issue Mar 16, 2018 · 4 comments
Open

Reliable argument handling #76

Stebalien opened this issue Mar 16, 2018 · 4 comments

Comments

@Stebalien
Copy link
Member

Currently, we allow users to mix optional, variadic, and required arguments. In order of preference:

  1. make this impossible (see below)
  2. check at start
  3. check when calling the command

We currently do none of these. Instead, we have some weird logic in CheckArguments where we stop filling in optional arguments once we realize we'll need the rest to fill in required arguments.


Preferred solution:

type Command struct {
	Arguments Arguments
	// ...
}
    
type Arguments struct {
	Required []Argument
	Optional []Argument
	Variadic Argument
}
@Stebalien
Copy link
Member Author

Oh, and guess what! We do this dance twice (IN A ROW!).

@keks
Copy link
Contributor

keks commented Apr 20, 2018

What do you mean with mix arguments? I agree the logic around checking the arguments is messed up, but I don't get why you want to split them in an Arguments struct.

@Stebalien
Copy link
Member Author

Because we can, e.g., put optional arguments before mandatory arguments and variadic arguments before either.

@keks
Copy link
Contributor

keks commented Sep 17, 2018

I think I start to get it. I'll be working on this once cmds2 is in.

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

No branches or pull requests

2 participants