-
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
Improve CLI a bit (output formatting and bug fix) #799
Conversation
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.
@@ -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); |
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.
[PROMPT] maybe?
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.
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.
Fine by me, unsure if it needed a new file though.
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.
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(" "); | ||
}; |
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.
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?
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.
Keep in log for now.
const read = require("read"); | ||
|
||
module.exports = (options, callback) => { | ||
options.prompt = log.prompt(options.text); |
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.
prompt
!= text
on purpose for 2 reasons:
- We could still use
prompt
if we want to define a tailor-made CLI prompt without thelog.prompt
(we'll need to do... = options.prompt || ...
or something though) prompt({ prompt: "..." }, ...);
feels weird to me :D
Stupid? 😅
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 think we can do it simpler. log.prompt("Password:", (err, password) => {});
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.
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.
1bc0810
to
770ede0
Compare
Should be all set, @xPaw! |
This is a small PR, but with a big enough diff: I'll wait for a second review before merging. |
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 fine to me
…and-line-output Improve CLI a bit (output formatting and bug fix)
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.