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

Use Struct for flags/options #14

Open
mrrooijen opened this issue Aug 7, 2017 · 0 comments
Open

Use Struct for flags/options #14

mrrooijen opened this issue Aug 7, 2017 · 0 comments

Comments

@mrrooijen
Copy link
Owner

It'd be nice if we could figure out a way to use a Struct rather than a Hash for retrieving options from flags. Currently we have to do the following:

options.string["env"]    # => "development"
options.int["port"]      # => 8080
options.float["timeout"] # => 29.5
options.bool["verbose"]  # => false

It'd be nice if we could simply do the following instead:

options.env     # => "development"
options.port    # => 8080
options.timeout # => 29.5
options.verbose # => false

This way there will be no need to perform Nil-checks since there won't be any potentially missing keys unlike with Hashes.

Not sure how to accomplish this yet. Potentially with the use of macros to dynamically build structs at compile-time. Or, perhaps allow the user to manually define a struct and pass it in to the flags. Haven't looked into it yet.

@mrrooijen mrrooijen changed the title Use Struct for flags Use Struct for flags/options Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant