Skip to content
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

Show scopes in apis subcommands instead of count #174

Merged
merged 14 commits into from
Mar 24, 2021

Conversation

chrisscott
Copy link
Contributor

Description

  • For apis subcommands that show scopes use a truncated list, based on terminal width, to show the scopes instead of the count. Use an ellipsis to denote the truncation.
  • For the apis show subcommand, add an info to note that the full scopes can be viewed using auth0 apis scopes list <api-id>.

The truncation function handles conversion of the length of UTF strings to characters and truncates based on terminal width. If truncation is needed by other commands this can be refactored.

There is an off by one bug in the truncation but it errs on the side of truncating too much so won't affect display.

The padding for the left column of the table is fixed but could be refactored to use reflection to determine the max length of the apiView struct and apply the pre- and post-spacing in the display to account for future additions to the struct.

References

Fixes #150

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

…n terminal width, to show the scopes instead of the count. Use an ellipsis to shdenote the truncation.

For the `apis show` subcommand, add an info to note that the full scopes can be viewed using `auth0 apis scopes list <api-id>`.
internal/display/apis.go Outdated Show resolved Hide resolved
internal/cli/apis.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, need to fix the table view and add the app id to the hint 💪🏻

internal/display/apis.go Outdated Show resolved Hide resolved
@@ -110,3 +155,35 @@ func makeScopeView(scope *management.ResourceServerScope) *scopeView {
Description: auth0.StringValue(scope.Description),
}
}

func truncateScopes(scopes []*management.ResourceServerScope) *string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2021-03-22 at 13 51 50

Scopes that fit shouldn't be truncated.
Also let's not display the hint if the scopes are not truncated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 good catch. Refactoring this now to bring the hint into the display logic instead of the cli logic.

Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, let's not truncate the scopes that fit.
Thank you!

Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you

@Widcket Widcket merged commit b518b64 into main Mar 24, 2021
@Widcket Widcket deleted the cli-71-apis-list-truncate-scopes branch March 24, 2021 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apis show should show scopes [CLI-71]
2 participants