-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Feat/add required flags #110
Conversation
…rt required functions and booleans
…h required message
Please don't do unrelated changes. Revert the Prettier changes. Unrelated changes makes it very hard to review the actual changes. |
I think that should be |
From #51 (comment):
|
This is also unanswered:
|
@@ -13,7 +13,17 @@ const cli = meow({ | |||
flags: { | |||
unicorn: {alias: 'u'}, | |||
meow: {default: 'dog'}, | |||
camelCaseOption: {default: 'foo'} | |||
camelCaseOption: {default: 'foo'}, | |||
fence: { |
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.
It would be better to create a new fixture file for just testing the required flag stuff.
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.
Okay. Will include this
t.is(stdout, 'Missing required option:\n --foo, -o\n\nRun with --help to view help information.'); | ||
}); | ||
|
||
test('provisional require', async t => { |
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.
The title needs to be clearer. I'm not sure what exactly is being tested 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.
The test is for optional required flags. Will update the description to make it clearer
'cat' | ||
]); | ||
|
||
t.is(i, 'Missing required option:\n --fence, -f\n\nRun with --help to view help information.'); |
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.
You also need a test for the positive side, when --fence
is actually given.
]); | ||
|
||
t.is(i, 'Missing required option:\n --fence, -f\n\nRun with --help to view help information.'); | ||
t.is(f, 'Missing required option:\n --foo, -o\n\nRun with --help to view help information.'); |
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.
It would be better to test only the important part of the message, so other parts are free to change in the future without having to update all the tests. You can use t.regex
instead.
All we need to test is Missing required option:\n --foo, -o
.
]); | ||
t.is( | ||
help, | ||
indentString('\nCustom description\n\nUsage\n foo <input>\n\n', 2)); |
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.
Use t.regex
here to simplify the assertion.
I think the function arguments should be the |
@HackAfro Still interested in finishing this? |
Yes. Let me make these changes and update the PR |
@HackAfro Bump |
Closing for lack of response. |
Fixes #51.
This pull request attempts adding the feature to enable required flags.
Examples:
Output without required flag:
fixture --unicorn="horns"
The command above would make
fence
a required flag. Meaningfence
is only required ifunicorn
is present.