-
Notifications
You must be signed in to change notification settings - Fork 9
Remove left & right trimming? #71
Comments
Agreed. Maybe a python like |
i think you could use https://github.com/sindresorhus/strip-indent to do a dedent. here's what I'm working with: Much better than the output of commander, but I'd love to give it a bit of padding :-) |
That's one good looking CLI. Makes me wonder what does your neodoc source string look like to get all the colors going? I'd imagine a lot of these guys: |
Do you mind providing a simple example for this? I have checked the sources, I am actually not de-denting the Line 143 in 1a62a37
|
Certainly, here's a trimmed version of the code: thimble #!/usr/bin/env node
const { run } = require('neodoc')
const chalk = require('chalk')
const argv = run(`
${chalk.inverse(' THIMBLE ')} A scaffolding system that grows with you.
${chalk.blue('I. Usage')}:
thimble <command> [<args>...]
thimble -h | --help
thimble --version
`) run:
You'll notice that despite having some extra padding and whitespace on both sides, it'll still hug the left side. It's totally your call on what you think is best, but I think since most people will have this code top-level (as opposed to inside an if statement block), it won't be unexpected to not dedent. |
On second thought, I definitely think you should just leave the dedenting, trimming up to the implementer of the CLI.
This probably allows you to reduce the codebase a bit. |
Thank you for providing the example and I agree with your reasoning. But what do you think about removing the very first (and maybe last) newline character? This way if you want padding, you just add another line. E.g.:
I've updated the JS test bed to able to test these things and have made corresponding adjustments to the code, but it would be good if we could agree on this. In part I disagree with myself with the above because the behavior is implicit and cannot be turned off. However, I think it would make it more usable and avoids extra function call clutter or even bringing in another dependency. Edit: To re-iterate: what I mean is that this approach would be less radical than trimming to the first non-ws character (only remove first and last empty line) and it would not mess with the indentation at all. |
This also adds chalk to the project as a devDependency.
I've implemented the above behavior and adjusted the test case: Lines 195 to 213 in a1b375f
It just boils down to this regular expression: Line 185 in a1b375f
...which reminds me of http://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016 :/ But I think our inputs are small enough and in complete control of the user that this is non-issue. |
This also adds chalk to the project as a devDependency.
Totally agree! Forgot about the first and last Awesome, thanks for your hard work! |
Sweet, I'll merge this then and create a patch release. |
Sorry one more thing that would be nice to have. Right now the library trims the left and right spacing from the input. The thing I love about this library is that you can sort of make your CLI however you want with just a few standard expressions. For my CLI, I'm finding that adding a bit of spacing would make things a bit easier to read.
The text was updated successfully, but these errors were encountered: