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

Important bug fixes #208

Merged
merged 6 commits into from
Jun 24, 2016
Merged

Important bug fixes #208

merged 6 commits into from
Jun 24, 2016

Conversation

leo
Copy link
Collaborator

@leo leo commented Jun 23, 2016

@leo leo changed the title Update args Update args & fix #185 Jun 23, 2016
@leo leo changed the title Update args & fix #185 Update args & fix issue with -h Jun 23, 2016
@leo leo mentioned this pull request Jun 23, 2016
@@ -6,7 6,7 @@ var slackin = require('./../node').default;

args
.option(['p', 'port'], 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000)
.option(['h', 'hostname'], 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0')
.option(['H', 'hostname'], 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the hostname arg should remain as h (lowercase) for backwards compatibility. That's the way it was before args got introduced:

.option('-h, --hostname <hostname>', 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0')
and changing it will probably break some people's deployments.

Copy link
Collaborator Author

@leo leo Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the option opens the help by default: #185. This issue has been opened before args was introduced. The problem already existed we therefore need to rename it to -H.

Besides of that, people shouldn't deploy straight from the master branch (but rather deploy the tree of the latest release). I will adjust the PR for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's no way to get the tree for the latest tag automatically. That means we would have to adjust the version tag within README.md each time a new version gets released. And since that's not sustainable, I guess we'll have to keep deploying master.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that there should be different flags used for help and hostname, just wanna point out that help wasn't getting open by default previously when passing -h.

-h would always be interpreted as hostname, see this comparison of the commit just before the refactor and the commit just after:

Old version (4ea80c4)

$ bin/slackin -h
error: option `-h, --hostname <hostname>' argument missing

$ bin/slackin -h "0.0.0.0" -p 8888 [subdomain] [api_key] 
Thu Jun 23 2016 19:41:15 GMT 1000 (AEST) – fetching
Thu Jun 23 2016 19:41:15 GMT 1000 (AEST) – listening on 0.0.0.0:8888
Thu Jun 23 2016 19:41:16 GMT 1000 (AEST) – ready

New version (1512684)

$ bin/slackin -h
bin/slackin -h

  Usage: slackin [options] [command] <team-id> <api-token>

  Commands:

    help  Display help

  Options:

    -c, --channels          One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]
    -C, --coc               Full URL to a CoC that needs to be agreed to
    -S, --css               Full URL to a custom CSS file to use on the main page
    -h, --help              Output usage information
    -h, --hostname [value]  Hostname to listen on [$HOSTNAME or 0.0.0.0]
    -i, --interval <n>      How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]
    -P, --path [value]      Path to serve slackin under
    -p, --port <n>          Port to listen on [$PORT or 3000]
    -s, --silent            Do not print out warns or errors
    -v, --version           Output the version number



$ bin/slackin -h "0.0.0.0" -p 8888 [subdomain] [api_key]

  Usage: slackin [options] [command] <team-id> <api-token>

  Commands:

    help  Display help

  Options:

    -c, --channels          One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]
    -C, --coc               Full URL to a CoC that needs to be agreed to
    -S, --css               Full URL to a custom CSS file to use on the main page
    -h, --help              Output usage information
    -h, --hostname [value]  Hostname to listen on [$HOSTNAME or 0.0.0.0]
    -i, --interval <n>      How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]
    -P, --path [value]      Path to serve slackin under
    -p, --port <n>          Port to listen on [$PORT or 3000]
    -s, --silent            Do not print out warns or errors
    -v, --version           Output the version number

I'm worried that changing -h to -H for hostname will break previously working deployments in favour of clearer CLI options - though that might be a tradeoff @rauchg is happy with.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexpls One thing I could do on my side is add the ability to overwrite -h within the "args" package. What do you think about that? I feel like it's a good thing on one hand, but on the other, it confuses people because most CLIs are using -h for the usage information.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the label of the flags just comes down to personal taste in the end. My suggestion would be to do something similar to what MySQL and Redis do, where -h is the hostname flag and -? is the help flag.

That would have the benefit of keeping -h backwards compatible, and since the help page is shown when incomplete arguments are passed to the slackin command, anyone who would type in slackin -h should still get shown the help page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented it exactly like you said! Works fine now. Please note that I had to fix the path to the build output (like you did it in your PR) to be able to test it. Because I've also added babel-register, I think you can close #204, if you want.

I'll make sure to mention you in the description section of the PR!

@leo leo changed the title Update args & fix issue with -h Important bug fixes Jun 23, 2016
This was referenced Jun 23, 2016
@cellar-door
Copy link

Can confirm that this fixes issues I had with deploying directly to Heroku.

@rauchg rauchg merged commit 4be8986 into rauchg:master Jun 24, 2016
@rauchg
Copy link
Owner

rauchg commented Jun 24, 2016

done :)

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

Successfully merging this pull request may close these issues.

Error: Cannot find module './../node'
4 participants