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
[Feature Request] Hide default value and flag type #1145
Comments
Afaik, there is no option to change the formatting of the of the help print out yet, besides usage() and epilogue() which will add a header/footer to it |
@bcoe Would you a pull request of a function like |
Another suggestion would be |
I have the same issue, when i add a description + a type, yargs pollutes the output. (--help) |
@borela there's now a way to configure advanced parsing options with Do you want to help add this feature? |
That would great, a flag to hide the flag type would be interesting too, for example |
|
Here's a quick fix that solves the issue for me.
let x; const brackets = (v, suffix='') => ((x=__(v))!=='-') && `[${x}${suffix}]` || null;
The patched section in file index.cjs (around line 900) looks like this: let x; const brackets = (v, suffix='') => ((x=__(v))!=='-') && `[${x}${suffix}]` || null;
displayedGroups.forEach(({ groupName, normalizedKeys, switches }) => {
ui.div(groupName);
normalizedKeys.forEach((key) => {
const kswitch = switches[key];
let desc = descriptions[key] || '';
let type = null;
if (~desc.lastIndexOf(deferY18nLookupPrefix))
desc = __(desc.substring(deferY18nLookupPrefix.length));
if (~options.boolean.indexOf(key))
type = brackets('boolean');
if (~options.count.indexOf(key))
type = brackets('count');
if (~options.string.indexOf(key))
type = brackets('string');
if (~options.normalize.indexOf(key))
type = brackets('string');
if (~options.array.indexOf(key))
type = brackets('array');
if (~options.number.indexOf(key))
type = brackets('number');
const deprecatedExtra = (deprecated) => typeof deprecated === 'string'
? `[${__('deprecated: %s', deprecated)}]`
: `[${__('deprecated')}]`;
const extra = [
(key in deprecatedOptions) ? brackets('deprecated') && deprecatedExtra(deprecatedOptions[key]) : null,
type,
(key in demandedOptions) ? brackets('required') : null,
options.choices && options.choices[key] ? brackets('choices:', ` ${self.stringifiedValues(options.choices[key])}]`) : null,
brackets('default:') && defaultString(options.default[key], options.defaultDescription[key])
].filter(Boolean).join(' ');
ui.span({ text: getText(kswitch), padding: [0, 2, 0, 2 + getIndentation(kswitch)], width: maxWidth(switches, theWrap) + 4 }, desc);
if (extra)
ui.div({ text: extra, padding: [0, 0, 0, 2], align: 'right' });
else
ui.div();
});
ui.div();
}); The application that calls yargs.updateStrings({
'boolean': '-',
'string': '-',
'count': '-',
'array': '-',
'number': '-',
'choices:': '-',
'default:': '-',
}) |
My use case is a "github token" argument, which defaults from |
Any updates on this feature? |
Not a very important complaint in our case, but it's a bit annoying that Even though they are booleans, no reasonable person is passing |
@06000208 per #2156 (comment), that does not cover this issue, since it doesn't allow the type to be hidden on arbitrary options, only on everything all at once. |
@ljharb please feel free to open an additional feature request for hiding the default/type suffixes for individual commands. Closing this as it addresses the feature request in this ticket (which was to turn the feature on or off globally). |
Fair enough, opened #2299. |
Currently, my project shows:
But the default values and types pollutes it, is it possible already to hide them? I would like something like this:
The text was updated successfully, but these errors were encountered: