-
Notifications
You must be signed in to change notification settings - Fork 34
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
Override yargs help output with custom help renderer #229
Conversation
Am completely open to suggestions to the formatting and colours and also if I've missed anything. |
Codecov Report
@@ Coverage Diff @@
## master #229 +/- ##
==========================================
- Coverage 95.04% 94.13% -0.92%
==========================================
Files 19 20 +1
Lines 525 597 +72
Branches 70 95 +25
==========================================
+ Hits 499 562 +63
- Misses 13 17 +4
- Partials 13 18 +5
Continue to review full report at Codecov.
|
Needs more test coverage! |
4f33e59
to
5dfce09
Compare
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 good visually. Might be worth using the cliui
package for layout
@@ -19,12 +15,12 @@ export type RenderFilesConfig = { | |||
* allowing commands to call one another. Provides 'run' and 'exists' functions | |||
*/ | |||
export class SingleCommandHelper implements CommandHelper { | |||
private _commandsMap: CommandsMap; | |||
private _groupMap: GroupMap; |
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.
Funny that we're renaming these to "commands" in the README and changing them FROM commands in the code 😂
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.
Yeah it’s because we already have a commands map that is the value of the group map. Traditionally it’s easier to understand these things as different (as they really are) when it comes to code. Open to other name suggestions though.
@@ -26,6 +25,8 @@ export function initCommandLoader(searchPrefixes: string[]): (path: string) => C | |||
alias, | |||
description, | |||
register, | |||
installed: true, | |||
global: group === 'create' && name === 'app' ? true : global, |
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.
Maybe we should move this into a utility or something so that the next time we need to force a global like this we don't have to modify the logic in here?
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.
This is a totally temporary thing, this PR introduces an optional global property on the API that commands can mark whether that are global and then we can remove this logic completely
@tomdye I think for now the padding works but I defo want to look at using cli-table for the layout. |
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.
One test description should be clearer. Overall the code looks fine, I don't know enough about this space to know if you've introduced any regressions.
} | ||
}); | ||
|
||
it('Should not return validation error for when option provided', () => { |
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.
"Should not return validation error for when option provided" might want to make this clearer?
wow that's fancy :) |
Art courtesy of @matt-gadd 😄 |
Type: feature
The following has been addressed in the PR:
prettier
as per the readme code style guidelinesDescription:
Handles help output explicitly for the CLI and commands with a custom help renderer. Also needed some significant changes in the way that commands are registered:
CommandMap
andYargsCommandNames
to a singleGroupMap
so that they are not managed over two objectsglobal
, defaults tofalse
CommandWrapper
-global
,installed
,default
default
is set on the first registered command for a group (same as before)installed
is set to false for commands found fromnpm
aliases
as no commands currently use it and it complicates the help renderer.Temporarily hard coded
create-app
to be a global command as it's the "dojo" global external command.Main CLI help output
Group CLI help output
Command CLI help output
Installable command CLI help output
Resolves #227
Resolves #228