-
Notifications
You must be signed in to change notification settings - Fork 11
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: allow stdin for sfdx-url #886
feat: allow stdin for sfdx-url #886
Conversation
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.
Just a light edit. This is no guarantee that we'll accept your contribution! But I noticed it and thought I'd give you some suggestions. Thx.
Co-authored-by: Juliet Shackell <[email protected]>
Co-authored-by: Juliet Shackell <[email protected]>
Co-authored-by: Juliet Shackell <[email protected]>
Co-authored-by: Juliet Shackell <[email protected]>
@k-capehart Thanks for taking this on! As you noted, this change would allow someone to pass the url directly to the flag. I just made a PR to oclif/core that adds an That way we don't open up the possibility for people to provide the url directly |
Perfect! I'll update this PR to reflect that new change in oclif. Thanks. |
@k-capehart FYI, I merged the oclif/core PR. Changes should be available in 3.16.0 |
@mdonnalley Thanks for your help. This PR has been updated to reflect the new changes and is ready for review now. |
@jshackell-sfdc Also, I updated the documentation if you don't mind reviewing again. Thank you! |
@@ -33,10 +33,18 @@ export default class LoginSfdxUrl extends AuthBaseCommand<AuthFields> { | |||
'sfdx-url-file': Flags.file({ | |||
char: 'f', | |||
summary: messages.getMessage('flags.sfdx-url-file.summary'), | |||
required: true, | |||
required: false, |
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.
We should add this to both sfdx-url-file
and sfdx-url-stdin
to ensure that people provide one of those
exactlyOne: ['sfdx-url-file', 'sfdx-url-stdin']
Doing that would allow you to drop the validation logic you have on lines 88-96
We should also add exclusive: ['sfdx-url-stdin']
to make sure that people don't provide both
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.
@mdonnalley I added these suggestions but kept the validation logic, otherwise I get a compiler error that sfdxAuthUrl
could be undefined. I think that's because its not smart enough to know that one of the flags are guaranteed to be provided. Let me know if you know a work-around, but I think that's consistent with other implementations.
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.
@k-capehart I think exclusive
is implied in exactlyOne
so there's not actually a need for both - you only need exactlyOne
on both flags
Sorry about that - should have tested it all out before asking you to make a change!
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.
@mdonnalley Oh makes sense, that explains the repetition in error messages I was seeing. I removed it 👍
deprecateAliases: true, | ||
aliases: ['sfdxurlfile'], | ||
}), | ||
'sfdx-url-stdin': Flags.file({ |
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.
We should add exclusive: ['sfdx-url-file']
to make sure that people don't provide both
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.
@mdonnalley, question: It sounds to me like --sfdx-url-stdin
can take only one value (-
), and if it's present then the user is doing the piping-through-stdin thing. So wouldn't it make more sense to make --sfdx-url-stdin
a Boolean flag? Or maybe I'm missing something.
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.
I can provide some context, this is what I based the solution on: oclif/core#761 (comment)
In this case, the value should always be -
but that is consistent with CLI standards because oclif requires the -
value in order to read from standard input.
Co-authored-by: Juliet Shackell <[email protected]>
Co-authored-by: Juliet Shackell <[email protected]>
@mdonnalley @jshackell-sfdc I appreciate you both! It's exciting to get this one working. |
QA Setup:
✅ Great work @k-capehart 🏆 |
@k-capehart I'm going to merge this into a separate feature branch first so that all our integration tests can run. Once those pass I'll merge to main |
* feat: allow stdin for sfdx-url * Update messages/sfdxurl.store.md * Update messages/sfdxurl.store.md * Update messages/sfdxurl.store.md * Update messages/sfdxurl.store.md * feat: create new --sfdx-url-stdin flag * feat: remove unnecessary error * feat: allowStdin set to 'only' * Update messages/sfdxurl.store.md * feat: add suggestions to make flags exclusive and required * feat: remove exclusive option, as it is implied with exactlyOne * Update messages/sfdxurl.store.md --------- Co-authored-by: Kyle Capehart <[email protected]> Co-authored-by: Juliet Shackell <[email protected]>
What does this PR do?
allowStdin
--sfdx-url-stdin
and hasallowStdin: 'only'
--sfdx-url-file
is no longer required, so an error is thrown if neither--sfdx-url-stdin
or--sfdx-url-file
are given$ echo url | sf org login sfdx-url --sfdx-url-stdin -
What issues does this PR fix or reference?
closes: forcedotcom/cli#2120
[skip-validate-pr]