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

Improve CLI a bit (output formatting and bug fix) #799

Merged
merged 3 commits into from
Dec 19, 2016

Conversation

astorije
Copy link
Member

First commit was started as a finishing touch of this, then I went a bit more crazy.

Second commit of this PR should fix #517.
I know it is proposed to deprecate them in favor of a more generic one (-c port=80), but in the meantime the existing ones should work properly.

I know it is proposed to deprecate them in favor of a more generic one (`-c port=80`), but in the meantime the existing ones should work properly.
@astorije astorije added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Dec 15, 2016
@astorije astorije changed the title Astorije/improve command line output Improve CLI a bit (output formatting and bug fix) Dec 15, 2016
@astorije astorije added the Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors. label Dec 15, 2016
@@ -30,3 +30,8 @@ exports.info = function() {
exports.debug = function() {
console.log.apply(console, timestamp(colors.green("[DEBUG]"), arguments));
};

exports.rawInfo = function() {
const newArguments = timestamp(colors.blue("[INFO]"), arguments);
Copy link
Member

Choose a reason for hiding this comment

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

[PROMPT] maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

@xPaw, done, what do you think of 1bc0810. Is it overkill to define a utility helper for that? I'm thinking we'll have more of these, especially when considering things like #773 or other improvements to the CLI.

Copy link
Member

Choose a reason for hiding this comment

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

Fine by me, unsure if it needed a new file though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where would you put the helper then, since it's used in 2 places, maybe more soon-ish?

exports.rawInfo = function() {
const newArguments = timestamp(colors.blue("[INFO]"), arguments);
exports.prompt = function() {
const newArguments = timestamp(colors.cyan("[PROMPT]"), arguments);
return Array.prototype.slice.call(newArguments).join(" ");
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Where/How this function is defined feels wacky to me. It's in the log file, but it's not a log, but it's using formatting to look like a log, and it's using code from the log file... Any suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Keep in log for now.

const read = require("read");

module.exports = (options, callback) => {
options.prompt = log.prompt(options.text);
Copy link
Member Author

Choose a reason for hiding this comment

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

prompt != text on purpose for 2 reasons:

  • We could still use prompt if we want to define a tailor-made CLI prompt without the log.prompt (we'll need to do ... = options.prompt || ... or something though)
  • prompt({ prompt: "..." }, ...); feels weird to me :D

Stupid? 😅

Copy link
Member

Choose a reason for hiding this comment

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

I think we can do it simpler. log.prompt("Password:", (err, password) => {});

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. It bothers me a little bit that there is a CLI-only helper in log which is used everywhere, but I don't care much, it works that way.

@astorije astorije requested a review from xPaw December 16, 2016 07:33
@astorije astorije force-pushed the astorije/improve-command-line-output branch from 1bc0810 to 770ede0 Compare December 17, 2016 03:46
@astorije
Copy link
Member Author

Should be all set, @xPaw!

@astorije astorije added this to the 2.2.0 milestone Dec 17, 2016
@astorije
Copy link
Member Author

This is a small PR, but with a big enough diff: I'll wait for a second review before merging.

@xPaw xPaw requested a review from AlMcKinlay December 19, 2016 10:56
Copy link
Member

@AlMcKinlay AlMcKinlay left a comment

Choose a reason for hiding this comment

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

Looks fine to me

@xPaw xPaw merged commit b9047d9 into master Dec 19, 2016
@xPaw xPaw deleted the astorije/improve-command-line-output branch December 19, 2016 12:18
matburnham pushed a commit to matburnham/lounge that referenced this pull request Sep 6, 2017
…and-line-output

Improve CLI a bit (output formatting and bug fix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors. Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mode flags for "start" command don't work
3 participants