-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Argument parsing in function #110
Comments
There is |
@Hejsil could you provide an example usage in the above snippet? Simply putting it as |
Something along the lines of this: const params = ...;
pub fn parseAndValidateArgs() !clap.Result(clap.Help, params, clap.parsers.default) {
const cliArgs = try clap.parse(clap.Help, params, clap.parsers.default);
// validate here
// then return
return cliArgs;
} |
It works, thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to refactor argument parsing into a separate function. It would parse the arguments, and validate them (min/max for numbers, permissions for file paths, etc.), then return the result of the parse function.
How do I specify the return type of the
parseAndValidateArgs
function in the above snippet? Is there a clean and readable way of doing it?The text was updated successfully, but these errors were encountered: