Closed tommy-mitchell closed 1 year ago
Related: #95
What's the argument? It looks better when surrounded by newlines. The bar for adding options is high. I doubt I would add an option for something as minor as this.
I agree not an option, though I think it can be a little unintuitive that meow('single line usage info')
becomes
$ my-command
single line usage info
I expected it to be
$ my-command
single line usage info
For example, cp
has the following usage info:
$ cp
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file ... target_directory
Perhaps if the provided help text has no newlines, it could be outputted without a leading newline.
However, I do understand the argument for readibility with spacing and enforcing best practices on users. Feel free to close this.
Maybe we could not indent it if it's a single line? That would make it look slightly nicer.
I'd be okay with that.
Ok. Let's do that.
Should this extend to description
as well? Cases:
help
and description
are set - same behavior as now:
$ my-command
My command's description.
My command's help.
only help
is set - no indent:
$ my-command
My command's help.
only description
is set - no indent:
$ my-command
My command's description.
Related, should the fact that --version
is single-line have any bearing on this?
$ my-command --version
0.5.2
$
Should this extend to description as well? Cases:
Yes
@tommy-mitchell What do you think of removing the indent in meow
? I no longer remember why I added it and it seems like all the major CLI frameworks (swit-arguments-parser, Clap, Yargs, etc.) do not use an indent.
@sindresorhus I kind of like how it looks, but I think a simple indent
option would suffice:
meow(`
Usage
$ foo [--bar]
`, {
importMeta: import.meta,
indent: false,
flags: {
// ...
},
});
Where indent
is:
/* @default 2 */
indent: number | false
I also used to like it, but I'm seeing less value of it now for some reason. We can start with an option. We'll need that anyway if we decide to change the default in the future. Thanks.
https://github.com/sindresorhus/meow/issues/240#issuecomment-1698605364
Currently, help messages always have surrounding newlines:
https://github.com/sindresorhus/meow/blob/dc0e33cc33c890bbd8dd9c74d5e0db7173335fbb/index.js#L210
The user should be able to have a single line message (i.e. without a leading newline). This can either be an option or can be inferred if the provided help text has no newlines: