Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions doc/ovhcloud_completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## ovhcloud completion

Generate shell completion scripts

### Synopsis

Generate shell completion scripts for ovhcloud CLI.

To load completions in your current shell session:

bash:
source <(ovhcloud completion bash)

zsh:
source <(ovhcloud completion zsh)

fish:
ovhcloud completion fish | source

To make completions permanent, run:

ovhcloud completion install


```
ovhcloud completion [bash|zsh|fish|powershell] [flags]
```

### Options

```
-h, --help help for completion
```

### Options inherited from parent commands

```
-d, --debug Activate debug mode (will log all HTTP requests details)
-e, --ignore-errors Ignore errors in API calls when it is not fatal to the execution
-o, --output string Output format: json, yaml, interactive, or a custom format expression (using https://github.com/PaesslerAG/gval syntax)
Examples:
--output json
--output yaml
--output interactive
--output 'id' (to extract a single field)
--output 'nested.field.subfield' (to extract a nested field)
--output '[id, "name"]' (to extract multiple fields as an array)
--output '{"newKey": oldKey, "otherKey": nested.field}' (to extract and rename fields in an object)
--output 'name+","+type' (to extract and concatenate fields in a string)
--output '(nbFieldA + nbFieldB) * 10' (to compute values from numeric fields)
--profile string Use a specific profile from the configuration file
```

### SEE ALSO

* [ovhcloud](ovhcloud.md) - CLI to manage your OVHcloud services
* [ovhcloud completion install](ovhcloud_completion_install.md) - Install shell completion permanently in your shell rc file

37 changes: 37 additions & 0 deletions doc/ovhcloud_completion_install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## ovhcloud completion install

Install shell completion permanently in your shell rc file

```
ovhcloud completion install [flags]
```

### Options

```
-h, --help help for install
```

### Options inherited from parent commands

```
-d, --debug Activate debug mode (will log all HTTP requests details)
-e, --ignore-errors Ignore errors in API calls when it is not fatal to the execution
-o, --output string Output format: json, yaml, interactive, or a custom format expression (using https://github.com/PaesslerAG/gval syntax)
Examples:
--output json
--output yaml
--output interactive
--output 'id' (to extract a single field)
--output 'nested.field.subfield' (to extract a nested field)
--output '[id, "name"]' (to extract multiple fields as an array)
--output '{"newKey": oldKey, "otherKey": nested.field}' (to extract and rename fields in an object)
--output 'name+","+type' (to extract and concatenate fields in a string)
--output '(nbFieldA + nbFieldB) * 10' (to compute values from numeric fields)
--profile string Use a specific profile from the configuration file
```

### SEE ALSO

* [ovhcloud completion](ovhcloud_completion.md) - Generate shell completion scripts

28 changes: 16 additions & 12 deletions internal/cmd/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cmd

import (
"github.com/ovh/ovhcloud-cli/internal/assets"
"github.com/ovh/ovhcloud-cli/internal/completion"
"github.com/ovh/ovhcloud-cli/internal/services/account"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -63,10 +64,11 @@ func init() {
}))

oauth2ClientCmd.AddCommand(&cobra.Command{
Use: "get <client_id>",
Short: "Get details of an OAuth2 client",
Args: cobra.ExactArgs(1),
Run: account.GetOauth2Client,
Use: "get <client_id>",
Short: "Get details of an OAuth2 client",
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.ServiceList("/v1/me/api/oauth2/client"),
Run: account.GetOauth2Client,
})

oauth2CreateCmd := &cobra.Command{
Expand All @@ -85,17 +87,19 @@ func init() {
oauth2ClientCmd.AddCommand(oauth2CreateCmd)

oauth2ClientCmd.AddCommand(&cobra.Command{
Use: "delete <client_id>",
Short: "Delete the given OAuth2 client",
Args: cobra.ExactArgs(1),
Run: account.DeleteOauth2Client,
Use: "delete <client_id>",
Short: "Delete the given OAuth2 client",
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.ServiceList("/v1/me/api/oauth2/client"),
Run: account.DeleteOauth2Client,
})

oauth2ClientEditCmd := &cobra.Command{
Use: "edit <client_id>",
Short: "Edit an OAuth2 client",
Args: cobra.ExactArgs(1),
Run: account.EditOauth2Client,
Use: "edit <client_id>",
Short: "Edit an OAuth2 client",
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.ServiceList("/v1/me/api/oauth2/client"),
Run: account.EditOauth2Client,
}
oauth2ClientEditCmd.Flags().StringArrayVar(&account.Oauth2ClientSpec.CallbackUrls, "callback-urls", nil, "Callback URLs for the OAuth2 client")
oauth2ClientEditCmd.Flags().StringVar(&account.Oauth2ClientSpec.Description, "description", "", "Description of the OAuth2 client")
Expand Down
10 changes: 6 additions & 4 deletions internal/cmd/alldom.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cmd

import (
"github.com/ovh/ovhcloud-cli/internal/completion"
"github.com/ovh/ovhcloud-cli/internal/services/alldom"
"github.com/spf13/cobra"
)
Expand All @@ -26,10 +27,11 @@ func init() {

// Command to get a single AllDom
alldomCmd.AddCommand(&cobra.Command{
Use: "get <service_name>",
Short: "Retrieve information of a specific AllDom",
Args: cobra.ExactArgs(1),
Run: alldom.GetAllDom,
Use: "get <service_name>",
Short: "Retrieve information of a specific AllDom",
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.ServiceList("/v1/allDom"),
Run: alldom.GetAllDom,
})

rootCmd.AddCommand(alldomCmd)
Expand Down
Loading
Loading