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

OCM-1888: Add docs for ocm delete account command #592

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

cgiradkar
Copy link
Contributor

@cgiradkar cgiradkar commented Feb 1, 2024

Prevously when using the help in OCM-CLI it did not list all available sub commands.
This was due to how we currently alias urls in the CLI. Now added documentation about using the
urls(path) or provide a resource_id for the resource to be deleted.

Signed-off-by: Chetan Giradkar [email protected]

@cgiradkar cgiradkar changed the title OCM-1888: Add docs and implement ocm delete account command [WIP] OCM-1888: Add docs and implement ocm delete account command Feb 6, 2024
@cgiradkar cgiradkar force-pushed the OCM-1888-ocm-delete-account branch 3 times, most recently from 31e252d to b841440 Compare February 6, 2024 17:26
@cgiradkar cgiradkar changed the title [WIP] OCM-1888: Add docs and implement ocm delete account command OCM-1888: Add docs and implement ocm delete account command Feb 6, 2024
@cgiradkar cgiradkar marked this pull request as ready for review February 6, 2024 17:27
@cgiradkar cgiradkar force-pushed the OCM-1888-ocm-delete-account branch from b841440 to 6b6c601 Compare February 7, 2024 16:56
@@ -40,14 +40,49 @@ var args struct {
}

var Cmd = &cobra.Command{
Use: "delete [flags] PATH",
Use: "delete [flags] PATH|RESOURCE_ALIAS(with resource_id)",

Choose a reason for hiding this comment

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

I think we should be a bit more aligned with common documentation practices around command lines.

I propose two possible approaches:

One approach is listing the alternative uses:

delete [flags] PATH
delete [flags] RESOURCE_ALIAS RESOURCE_ID

The other is documenting it in a single line:

delete [flags] {PATH|RESOURCE_ALIAS RESOURCE_ID}

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest following the convention used by oc openshift CLI

Choose a reason for hiding this comment

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

oc / kubectl seems to use the single line approach (at least quickly checking some examples in there like oc label), with a different character for grouping:

I think it should be in the following way then:

delete [flags] (PATH | RESOURCE_ALIAS RESOURCE_ID)

@cgiradkar cgiradkar force-pushed the OCM-1888-ocm-delete-account branch from 6b6c601 to 25c273b Compare February 9, 2024 10:22
@cgiradkar cgiradkar changed the title OCM-1888: Add docs and implement ocm delete account command OCM-1888: Add docs for ocm delete account command Feb 12, 2024
@cgiradkar cgiradkar force-pushed the OCM-1888-ocm-delete-account branch from 25c273b to 5c6b11a Compare February 12, 2024 13:35
@cgiradkar cgiradkar requested a review from mnecas February 13, 2024 09:40
Short: "Send a DELETE request",
Long: "Send a DELETE request to the given path.",
RunE: run,
ValidArgs: urls.Resources(),
}

var usageTemplate = `Usage:{{if .Runnable}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we will adapt this template for other command we should move it to some utils so we don't need to move it when doing refactor of the other commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this template was picked up from cobra's internal help/usage template function: https://github.com/spf13/cobra/blob/bcfcff729ecdeb4072ef6f2a9c0b5e4ca1853206/command.go#L546

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed and decided to do it just for delete command and if it works properly without any breakages, then we can expand the scope. Also, it should not be a big task to make the template centralized.

@cgiradkar cgiradkar force-pushed the OCM-1888-ocm-delete-account branch from 5c6b11a to 2a44273 Compare March 12, 2024 15:15
@cgiradkar
Copy link
Contributor Author

Studied the template format from: https://pkg.go.dev/text/template to make necessary changes. Final o/p:
$ocm delete -h
image

@cgiradkar
Copy link
Contributor Author

Added a 2nd commit with format in string literal. Both commits to be compared side by side. @miguelsorianod , can you please compare and lets decide on what's the best format to merge?
I can then remove one of the commits before merging.

@miguelsorianod
Copy link

If the different parts of the template are not reused anywhere else I am fine with having it as a literal

Prevously when using the help in OCM-CLI it did not list all available sub commands.
This was due to how we currently alias urls in the CLI. Now added documentation about using the
urls(path) or provide a resource_id for the resource to be deleted. Another effort has been started
to understand and standardize the help format, which in turn will help in the task OCM-5179.
The template format has been used from https://pkg.go.dev/text/template.

Signed-off-by: Chetan Giradkar <[email protected]>
@cgiradkar cgiradkar force-pushed the OCM-1888-ocm-delete-account branch from 21f0b47 to 3423d52 Compare March 14, 2024 15:54
@cgiradkar
Copy link
Contributor Author

As discussed, I have used string literal format and added back the 2nd usage ([command]) and the O/P looks like following:
image

Copy link
Collaborator

@mnecas mnecas left a comment

Choose a reason for hiding this comment

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

@miguelsorianod could you ptal one last time?

@miguelsorianod
Copy link

It looks good to me.

I am assuming the output looks like the one shown in #592 (comment).

If that's not the case please upload a new capture to show the result.

@mnecas mnecas merged commit 798fb30 into openshift-online:main Apr 11, 2024
4 checks passed
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.

4 participants