-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add option to config to parse or not command line parameters #483
Conversation
I think a better solution would be an optional parameter to |
@straight-shoota actually that was my first approach but I felt it was invasive over the main run procedure, but I guess it would be fine too |
@straight-shoota would look like this: Kemal.run(args: nil) |
@@ -17,16 +17,24 @@ module Kemal | |||
self.run(nil) | |||
end | |||
|
|||
def self.run(args = ARGV) |
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.
This overload should be merged with the previous one.
src/kemal.cr
Outdated
# Overload of `self.run` to allow just a block. | ||
def self.run(&block) | ||
self.run nil, &block | ||
end | ||
|
||
def self.run(port : Int32?, args = ARGV ) |
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.
This overload should be merged with the first one.
src/kemal/cli.cr
Outdated
@ssl_enabled = false | ||
@key_file = "" | ||
@cert_file = "" | ||
@config = Kemal.config | ||
read_env | ||
parse | ||
if args != nil |
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.
just if args
is enough.
src/kemal/cli.cr
Outdated
@ssl_enabled = false | ||
@key_file = "" | ||
@cert_file = "" | ||
@config = Kemal.config | ||
read_env | ||
parse | ||
if args != nil | ||
parse |
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.
parse
should actually receive args
as argument and forward it to OptionParser#parse
. Otherwise this whole thing doesn't make any more sense than a simple flag.
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.
thank you for your feedback @straight-shoota !
Could you please apply the formatter ( |
sure, sorry. Not used to crystal tools. Thanks |
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.
Looks great. 👍
@sdogruyol Do you think we should have a spec for this?
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.
Actually, additions to the API docs would be nice!
This is great 👍 @diegogub would you like to add some API docs for this? |
@sdogruyol sure! |
Hi @sdogruyol , I added one line explaining this configuration, thanks |
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.
Thank you @diegogub 👍
thank you! @sdogruyol |
Description of the Change
Added option into config to avoid parsing command line parameters, sometime users want to define their own parameters instead of using Kemal ones.
Benefits
Freedom for users to choose others libs or other command line parameters without running into Kemal InvalidOption exception. For example I'm using : http://docopt.org/
Possible Drawbacks
I don't see any positive on keeping this feature, I cannot find the utility of a web framework reading defined command line parameters. Also It's not well documented.
Thank you!