Skip to content
Merged
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
10 changes: 9 additions & 1 deletion cli/commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import "testing"
func TestCommandTree(t *testing.T) {
root := NewRoot()
paths := [][]string{
{"functions"}, {"functions", "list"}, {"functions", "get"}, {"functions", "create"}, {"functions", "delete"},
{"functions"}, {"functions", "list"}, {"functions", "get"}, {"functions", "create"}, {"functions", "delete"}, {"functions", "update"},
{"deploy"},
{"deployments"}, {"deployments", "list"}, {"deployments", "get"}, {"deployments", "logs"},
{"rollback"},
{"invoke"},
{"logs"},
{"executions"}, {"executions", "list"}, {"executions", "get"}, {"executions", "logs"},
{"executions", "delete"}, {"executions", "prune"}, {"executions", "replay"},
{"kv"}, {"kv", "get"}, {"kv", "put"}, {"kv", "delete"}, {"kv", "list"}, {"kv", "incr"}, {"kv", "cas"},
{"cron"}, {"cron", "create"}, {"cron", "list"}, {"cron", "update"}, {"cron", "delete"},
{"jobs"}, {"jobs", "enqueue"}, {"jobs", "list"}, {"jobs", "get"}, {"jobs", "retry"}, {"jobs", "delete"},
Expand Down Expand Up @@ -94,6 +96,12 @@ func TestRequiredFlagsPresent(t *testing.T) {
{[]string{"cron", "create"}, "expr"},
{[]string{"webhooks", "create"}, "name"},
{[]string{"webhooks", "create"}, "url"},
{[]string{"webhooks", "update"}, "events"},
{[]string{"functions", "update"}, "network-mode"},
{[]string{"functions", "update"}, "env"},
{[]string{"executions", "list"}, "status"},
{[]string{"executions", "list"}, "limit"},
{[]string{"executions", "prune"}, "older-than"},
{[]string{"channels", "create"}, "functions"},
{[]string{"secrets", "set"}, "value"},
{[]string{"keys", "create"}, "expires-in-days"},
Expand Down
11 changes: 10 additions & 1 deletion cli/commands/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func wireCompletions(root *cobra.Command) {
// First positional = function name.
for _, path := range [][]string{
{"invoke"}, {"diff"}, {"rollback"}, {"logs"},
{"functions", "get"}, {"functions", "delete"},
{"functions", "get"}, {"functions", "delete"}, {"functions", "update"},
{"deployments", "list"}, {"deployments", "get"}, {"deployments", "logs"},
} {
if c, _, err := root.Find(path); err == nil && c.Name() == path[len(path)-1] {
Expand All @@ -155,6 +155,15 @@ func wireCompletions(root *cobra.Command) {
}
}

// --function flag = function name (executions filters).
for _, path := range [][]string{
{"executions", "list"}, {"executions", "prune"},
} {
if c, _, err := root.Find(path); err == nil {
_ = c.RegisterFlagCompletionFunc("function", completeFunctionNames)
}
}

// Enum + resource flags.
if c, _, err := root.Find([]string{"deploy"}); err == nil {
_ = c.RegisterFlagCompletionFunc("runtime", completeRuntimes)
Expand Down
Loading
Loading