-
Notifications
You must be signed in to change notification settings - Fork 700
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
Update arg parsing and default 'lounge' to 'lounge --help' #929
Update arg parsing and default 'lounge' to 'lounge --help' #929
Conversation
src/command-line/start.js
Outdated
@@ -13,6 +13,7 @@ program | |||
.option("-B, --bind <ip>", "bind") | |||
.option(" --public", "mode") | |||
.option(" --private", "mode") | |||
.parse(process.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.
@xPaw, do you know why ESLint would not catch 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, nevermind, I found the missing option and added it to #930.
@msaun008, sorry this is a nitpick, but can you replace the 2 spaces with 1 tab please? (Then use git add src/command-line/start.js && git commit --amend && git push --force
to not create an extra commit)
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.
I'm trying to understand why we need this here. I would assume the bug is happening in index.js
due to incorrect order of parsing. There's program.parseOptions
and program.parse
calls in there.
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.
Tried both changes and they work great, good catch @msaun008!
Asking for a second review in case I missed something obvious.
src/command-line/start.js
Outdated
@@ -13,6 +13,7 @@ program | |||
.option("-B, --bind <ip>", "bind") | |||
.option(" --public", "mode") | |||
.option(" --private", "mode") | |||
.parse(process.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.
Actually, nevermind, I found the missing option and added it to #930.
@msaun008, sorry this is a nitpick, but can you replace the 2 spaces with 1 tab please? (Then use git add src/command-line/start.js && git commit --amend && git push --force
to not create an extra commit)
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.
Sorry, I meant to approve the changes but not approve the PR because of the indentation request :)
src/command-line/index.js
Outdated
@@ -43,5 +43,5 @@ require("./edit"); | |||
program.parse(argv.args); | |||
|
|||
if (!program.args.length) { | |||
program.parse(process.argv.concat("start")); | |||
program.parse(process.argv.concat("--help")); |
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.
Instead of this crappy hack, can isDefault
be used?
EDIT: Since help is automated, program.help()
should be used.
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.
I wasn't clear so I asked clarification to @xPaw and:
--help
is auto-generated bycommander
, not something we define, so we can't useisDefault
on it.- Replace
program.parse(process.argv.concat("--help"));
withprogram.help()
.
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 makes sense.
@msaun008, fix to our linter was merged in master, could you rebase with the upstream project please? |
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.
fd73296
to
66795b0
Compare
Tested the fix @xPaw suggested. This works and I agree is the better fix. |
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 good to me, thank you very much @msaun008!!
(@xPaw, I haven't tested the new version, let me know if you want me to before we can merge)
@astorije I suspect that |
Argh, good catch... $ node index start --port 1234 --home /tmp
2017-02-24 23:23:00 [INFO] The Lounge source (66795b0) is now running using node 6.9.4 on darwin (x64)
2017-02-24 23:23:00 [INFO] Configuration file: /Users/jeremie/.lounge/config.js
2017-02-24 23:23:00 [INFO] Available on http://0.0.0.0:1234/ in private mode
2017-02-24 23:23:00 [INFO] Press Ctrl-C to stop And this time it' not fixed with Huuuuh we do need unit tests for the CLI that would have been detected :( |
Spend some time testing it, and there's really no easy way of handling global options, but here's the fix I came up with: https://gist.github.com/xPaw/224285fcae39f426159b252b39252097 The actual fix for passing options is this: -program.parse(argv.args);
+program.parse(process.argv); The other changes are just to improve CLI a little. |
@xPaw, regarding your cleanups, why removing the config path displayed? It saved me a couple times to see that info, considering how weirdly we handle the config path. |
@astorije OK, left it as it was. |
@msaun008, mind trying out the new fix suggested by @xPaw? |
66795b0
to
86ed0b6
Compare
@xPaw Great fix. Just finished testing.
|
Okay with this now, @xPaw? I tried to think and cannot think of another edge case we missed. |
@astorije OK. In release, document that there's |
This broke docker images :(. This looks like a change requiring a major bump per semver conventions imo |
If this was a library I would agree, but for an end-user client application, going from v2 to v3 simply because |
I agree, it does feel very ridiculous to require a major bump for this - but that's what semver dictates (depending on how you define your API surface). However, I think the CLI is part of the "API surface" that should be covered by semver in the case of thelounge. I have a feeling more people launching lounge via supervisor/systemd/pm2/etc. will run into this issue when upgrading to In hindsight and imo, I think the best course of action would've been to initially introduce a deprecation notice when running |
We never agreed to follow semver. I agree with the rest of your points (we probably should have deprecated this rather than just removing it), but for semver to mean something, we have to actually follow semver. We agreed at the beginning that we wouldn't follow semver because, as @astorije says, we are an end user application. |
Oh, I thought we adhered to it. That makes my point less valid 😄 |
Huh, I just noticed that @astorije put that we follow semver in the CHANGELOG, but from this irc conversation last year, I thought we had agreed we wouldn't. But maybe that was my assumption and no one else agreed.
|
I agree with both of you but I think we are overthinking this a little bit :) If we had moved starting a server from Also, considering our currently... ahem, questionable CLI, it's likely that a lot of changes would/will be breaking stuff :) I am fine to remove |
…ine-arg-parsing Update arg parsing and default 'lounge' to 'lounge --help'
This PR does 2 things:
lounge
with no arguments to default tolounge --help
.