You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to try falcon serve on MBP and I felt it quite annoyed me when I always typo as falcon server.
I then thought what if falcon command supports aliases like falcon server or falcon s.
In 5xruby after hack, next day after RubyConf Taiwan 2019, I started to try coding on subcommand aliases.
In the beginning, I code for falcon s as alias of falcon serve because it is shorter and similar to rails s.
Referece from rails/commands.rb, I wrote some codes blow.
Later on, I discussed with @ioquatix and I got some of his considerations.
We don't know if there will be a falcon server subcommand in the future.
It would be better to show 'did you mean?' part first.
Next round, I tried to send PR for Samovar gem.
When I dived into Samovar::Nested#parse, I found falcon s --bind http://localhost:3000 will go into @default part.
In Falcon::Command::Top, the nested method set up default: 'serve'.
It means when falcon s --bind http://localhost:3000 fail, it should fallback to run falcon serve --bind http://localhost:3000 with input ['s', '--bind', 'http://localhost:3000']. And then it failed because there is also no s subcommand in falcon serve so the return is error message "Could not parse token "s" in:" with falcon serve help text.
@ioquatix and I had another discussion about how to parse subcommand.
I think it would be better to check if input.first =~ /^-.*/ and we can deal something when this situation happens.
Alternative way is that we should parse the whole command and run on a correct order.
For the first way, it would be tricky. It's more better to use begin…rescue…end in @default part instead.The problem is I don't like the code smell because there is a lot of elsif and then begin…rescue…end inside of it.
For the second way, the #parse method will become very complex and some command line features like -- might be broken.
This experience met a lot of different situation and I can't send any PR finally. Just raise issue to record it.
The text was updated successfully, but these errors were encountered:
I think falcon is quite good and I want more people to try it. falcon server or falcon s aliases would be easier for most of Rubyists (I believe so) to just start without looking at README.
This is an experience feedback.
I started to try
falcon serve
on MBP and I felt it quite annoyed me when I always typo asfalcon server
.I then thought what if falcon command supports aliases like
falcon server
orfalcon s
.In 5xruby after hack, next day after RubyConf Taiwan 2019, I started to try coding on subcommand aliases.
In the beginning, I code for
falcon s
as alias offalcon serve
because it is shorter and similar torails s
.Referece from rails/commands.rb, I wrote some codes blow.
Later on, I discussed with @ioquatix and I got some of his considerations.
falcon server
subcommand in the future.Next round, I tried to send PR for Samovar gem.
When I dived into Samovar::Nested#parse, I found
falcon s --bind http://localhost:3000
will go into@default
part.In Falcon::Command::Top, the
nested
method set updefault: 'serve'
.It means when
falcon s --bind http://localhost:3000
fail, it should fallback to runfalcon serve --bind http://localhost:3000
with input['s', '--bind', 'http://localhost:3000']
. And then it failed because there is also nos
subcommand infalcon serve
so the return is error message "Could not parse token "s" in:" withfalcon serve
help text.@ioquatix and I had another discussion about how to parse subcommand.
I think it would be better to check if
input.first =~ /^-.*/
and we can deal something when this situation happens.Alternative way is that we should parse the whole command and run on a correct order.
For the first way, it would be tricky. It's more better to use
begin…rescue…end
in@default
part instead.The problem is I don't like the code smell because there is a lot ofelsif
and thenbegin…rescue…end
inside of it.For the second way, the
#parse
method will become very complex and some command line features like--
might be broken.This experience met a lot of different situation and I can't send any PR finally. Just raise issue to record it.
The text was updated successfully, but these errors were encountered: