This thread contains a patchset. You're looking at the original emails,
but you may wish to use the patch review UI.
Review patch
5
2
[PATCH 1/5] meta: Implement user-webhook ID completion
---
meta.go | 20 +++++++++++++++++++-
srht/metasrht/gql.go | 9 +++++++++
srht/metasrht/operations.graphql | 9 +++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/meta.go b/meta.go
index c54ab16..1666200 100644
--- a/meta.go
+++ b/meta.go
@@ -547,7 +547,7 @@ func newMetaUserWebhookDeleteCommand() *cobra.Command {
Use: "delete <ID>",
Short: "Delete a user webhook",
Args: cobra.ExactArgs(1),
- ValidArgsFunction: cobra.NoFileCompletions,
+ ValidArgsFunction: completeMetaUserWebhookID,
Run: run,
}
return cmd
@@ -603,3 +603,21 @@ func completeMetaUserWebhookEvents(cmd *cobra.Command, args []string, toComplete
}
return eventList, cobra.ShellCompDirectiveNoFileComp
}
+
+func completeMetaUserWebhookID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ ctx := cmd.Context()
+ c := createClient("meta", cmd)
+ var webhookList []string
+
+ webhooks, err := metasrht.CompleteUserWebhookId(c.Client, ctx)
+ if err != nil {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+
+ for _, webhook := range webhooks.Results {
+ s := fmt.Sprintf("%d\t%s", webhook.Id, webhook.Url)
+ webhookList = append(webhookList, s)
+ }
+
+ return webhookList, cobra.ShellCompDirectiveNoFileComp
+}
diff --git a/srht/metasrht/gql.go b/srht/metasrht/gql.go
index 33ac115..7f8a7e1 100644
--- a/srht/metasrht/gql.go
+++ b/srht/metasrht/gql.go
@@ -416,6 +416,15 @@ func UserWebhooks(client *gqlclient.Client, ctx context.Context) (profileWebhook
return respData.ProfileWebhooks, err
}
+func CompleteUserWebhookId(client *gqlclient.Client, ctx context.Context) (profileWebhooks *WebhookSubscriptionCursor, err error) {
+ op := gqlclient.NewOperation("query completeUserWebhookId {\n\tprofileWebhooks {\n\t\tresults {\n\t\t\tid\n\t\t\turl\n\t\t}\n\t}\n}\n")
+ var respData struct {
+ ProfileWebhooks *WebhookSubscriptionCursor
+ }
+ err = client.Execute(ctx, op, &respData)
+ return respData.ProfileWebhooks, err
+}
+
func CreateSSHKey(client *gqlclient.Client, ctx context.Context, key string) (createSSHKey *SSHKey, err error) {
op := gqlclient.NewOperation("mutation createSSHKey ($key: String!) {\n\tcreateSSHKey(key: $key) {\n\t\tfingerprint\n\t\tcomment\n\t}\n}\n")
op.Var("key", key)
diff --git a/srht/metasrht/operations.graphql b/srht/metasrht/operations.graphql
index 1bfed4f..068ad33 100644
--- a/srht/metasrht/operations.graphql
+++ b/srht/metasrht/operations.graphql
@@ -123,6 +123,15 @@ query userWebhooks {
}
}
+query completeUserWebhookId {
+ profileWebhooks {
+ results {
+ id
+ url
+ }
+ }
+}
+
mutation createSSHKey($key: String!) {
createSSHKey(key: $key) {
fingerprint
base-commit: f21dcc99fcf6fac78a3304a16208cd9f871fd82c
--
2.37.0
[PATCH 2/5] git: Implement user-webhook ID completion
---
git.go | 20 +++++++++++++++++++-
srht/gitsrht/gql.go | 9 +++++++++
srht/gitsrht/operations.graphql | 9 +++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/git.go b/git.go
index 124c505..a99ec79 100644
--- a/git.go
+++ b/git.go
@@ -659,7 +659,7 @@ func newGitUserWebhookDeleteCommand() *cobra.Command {
Use: "delete <ID>",
Short: "Delete a user webhook",
Args: cobra.ExactArgs(1),
- ValidArgsFunction: cobra.NoFileCompletions,
+ ValidArgsFunction: completeGitUserWebhookID,
Run: run,
}
return cmd
@@ -838,3 +838,21 @@ func completeGitUserWebhookEvents(cmd *cobra.Command, args []string, toComplete
}
return eventList, cobra.ShellCompDirectiveNoFileComp
}
+
+func completeGitUserWebhookID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ ctx := cmd.Context()
+ c := createClient("git", cmd)
+ var webhookList []string
+
+ webhooks, err := gitsrht.CompleteUserWebhookId(c.Client, ctx)
+ if err != nil {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+
+ for _, webhook := range webhooks.Results {
+ s := fmt.Sprintf("%d\t%s", webhook.Id, webhook.Url)
+ webhookList = append(webhookList, s)
+ }
+
+ return webhookList, cobra.ShellCompDirectiveNoFileComp
+}
diff --git a/srht/gitsrht/gql.go b/srht/gitsrht/gql.go
index 1bb4920..d2198db 100644
--- a/srht/gitsrht/gql.go
+++ b/srht/gitsrht/gql.go
@@ -543,6 +543,15 @@ func UserWebhooks(client *gqlclient.Client, ctx context.Context) (userWebhooks *
return respData.UserWebhooks, err
}
+func CompleteUserWebhookId(client *gqlclient.Client, ctx context.Context) (userWebhooks *WebhookSubscriptionCursor, err error) {
+ op := gqlclient.NewOperation("query completeUserWebhookId {\n\tuserWebhooks {\n\t\tresults {\n\t\t\tid\n\t\t\turl\n\t\t}\n\t}\n}\n")
+ var respData struct {
+ UserWebhooks *WebhookSubscriptionCursor
+ }
+ err = client.Execute(ctx, op, &respData)
+ return respData.UserWebhooks, err
+}
+
func UploadArtifact(client *gqlclient.Client, ctx context.Context, repoId int32, revspec string, file gqlclient.Upload) (uploadArtifact *Artifact, err error) {
op := gqlclient.NewOperation("mutation uploadArtifact ($repoId: Int!, $revspec: String!, $file: Upload!) {\n\tuploadArtifact(repoId: $repoId, revspec: $revspec, file: $file) {\n\t\tfilename\n\t}\n}\n")
op.Var("repoId", repoId)
diff --git a/srht/gitsrht/operations.graphql b/srht/gitsrht/operations.graphql
index 318feb0..e673315 100644
--- a/srht/gitsrht/operations.graphql
+++ b/srht/gitsrht/operations.graphql
@@ -160,6 +160,15 @@ query userWebhooks {
}
}
+query completeUserWebhookId {
+ userWebhooks {
+ results {
+ id
+ url
+ }
+ }
+}
+
mutation uploadArtifact($repoId: Int!, $revspec: String!, $file: Upload!) {
uploadArtifact(repoId: $repoId, revspec: $revspec, file: $file) {
filename
--
2.37.0
[PATCH 3/5] lists: Implement user-webhook ID completion
---
lists.go | 20 +++++++++++++++++++-
srht/listssrht/gql.go | 9 +++++++++
srht/listssrht/operations.graphql | 9 +++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/lists.go b/lists.go
index 7994615..21ec8fd 100644
--- a/lists.go
+++ b/lists.go
@@ -671,7 +671,7 @@ func newListsUserWebhookDeleteCommand() *cobra.Command {
Use: "delete <ID>",
Short: "Delete a user webhook",
Args: cobra.ExactArgs(1),
- ValidArgsFunction: cobra.NoFileCompletions,
+ ValidArgsFunction: completeListsUserWebhookID,
Run: run,
}
return cmd
@@ -840,3 +840,21 @@ func completeListsUserWebhookEvents(cmd *cobra.Command, args []string, toComplet
}
return eventList, cobra.ShellCompDirectiveNoFileComp
}
+
+func completeListsUserWebhookID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ ctx := cmd.Context()
+ c := createClient("lists", cmd)
+ var webhookList []string
+
+ webhooks, err := listssrht.CompleteUserWebhookId(c.Client, ctx)
+ if err != nil {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+
+ for _, webhook := range webhooks.Results {
+ s := fmt.Sprintf("%d\t%s", webhook.Id, webhook.Url)
+ webhookList = append(webhookList, s)
+ }
+
+ return webhookList, cobra.ShellCompDirectiveNoFileComp
+}
diff --git a/srht/listssrht/gql.go b/srht/listssrht/gql.go
index 0e70dad..438eb82 100644
--- a/srht/listssrht/gql.go
+++ b/srht/listssrht/gql.go
@@ -665,6 +665,15 @@ func UserWebhooks(client *gqlclient.Client, ctx context.Context) (userWebhooks *
return respData.UserWebhooks, err
}
+func CompleteUserWebhookId(client *gqlclient.Client, ctx context.Context) (userWebhooks *WebhookSubscriptionCursor, err error) {
+ op := gqlclient.NewOperation("query completeUserWebhookId {\n\tuserWebhooks {\n\t\tresults {\n\t\t\tid\n\t\t\turl\n\t\t}\n\t}\n}\n")
+ var respData struct {
+ UserWebhooks *WebhookSubscriptionCursor
+ }
+ err = client.Execute(ctx, op, &respData)
+ return respData.UserWebhooks, err
+}
+
func MailingListSubscribe(client *gqlclient.Client, ctx context.Context, listID int32) (mailingListSubscribe *MailingListSubscription, err error) {
op := gqlclient.NewOperation("mutation mailingListSubscribe ($listID: Int!) {\n\tmailingListSubscribe(listID: $listID) {\n\t\tlist {\n\t\t\tname\n\t\t\towner {\n\t\t\t\tcanonicalName\n\t\t\t}\n\t\t}\n\t}\n}\n")
op.Var("listID", listID)
diff --git a/srht/listssrht/operations.graphql b/srht/listssrht/operations.graphql
index 311c14e..f6362c9 100644
--- a/srht/listssrht/operations.graphql
+++ b/srht/listssrht/operations.graphql
@@ -169,6 +169,15 @@ query userWebhooks {
}
}
+query completeUserWebhookId {
+ userWebhooks {
+ results {
+ id
+ url
+ }
+ }
+}
+
mutation mailingListSubscribe($listID: Int!) {
mailingListSubscribe(listID: $listID) {
list {
--
2.37.0
[PATCH 4/5] hg: Implement user-webhook ID completion
---
hg.go | 20 +++++++++++++++++++-
srht/hgsrht/gql.go | 9 +++++++++
srht/hgsrht/operations.graphql | 9 +++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/hg.go b/hg.go
index 1620678..2112cbd 100644
--- a/hg.go
+++ b/hg.go
@@ -239,7 +239,7 @@ func newHgUserWebhookDeleteCommand() *cobra.Command {
Use: "delete <ID>",
Short: "Delete a user webhook",
Args: cobra.ExactArgs(1),
- ValidArgsFunction: cobra.NoFileCompletions,
+ ValidArgsFunction: completeHgUserWebhookID,
Run: run,
}
return cmd
@@ -278,3 +278,21 @@ func completeHgUserWebhookEvents(cmd *cobra.Command, args []string, toComplete s
}
return eventList, cobra.ShellCompDirectiveNoFileComp
}
+
+func completeHgUserWebhookID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ ctx := cmd.Context()
+ c := createClient("hg", cmd)
+ var webhookList []string
+
+ webhooks, err := hgsrht.CompleteUserWebhookId(c.Client, ctx)
+ if err != nil {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+
+ for _, webhook := range webhooks.Results {
+ s := fmt.Sprintf("%d\t%s", webhook.Id, webhook.Url)
+ webhookList = append(webhookList, s)
+ }
+
+ return webhookList, cobra.ShellCompDirectiveNoFileComp
+}
diff --git a/srht/hgsrht/gql.go b/srht/hgsrht/gql.go
index fabd9c6..5e6152c 100644
--- a/srht/hgsrht/gql.go
+++ b/srht/hgsrht/gql.go
@@ -345,6 +345,15 @@ func UserWebhooks(client *gqlclient.Client, ctx context.Context) (userWebhooks *
return respData.UserWebhooks, err
}
+func CompleteUserWebhookId(client *gqlclient.Client, ctx context.Context) (userWebhooks *WebhookSubscriptionCursor, err error) {
+ op := gqlclient.NewOperation("query completeUserWebhookId {\n\tuserWebhooks {\n\t\tresults {\n\t\t\tid\n\t\t\turl\n\t\t}\n\t}\n}\n")
+ var respData struct {
+ UserWebhooks *WebhookSubscriptionCursor
+ }
+ err = client.Execute(ctx, op, &respData)
+ return respData.UserWebhooks, err
+}
+
func CreateRepository(client *gqlclient.Client, ctx context.Context, name string, visibility Visibility, description string) (createRepository *Repository, err error) {
op := gqlclient.NewOperation("mutation createRepository ($name: String!, $visibility: Visibility!, $description: String!) {\n\tcreateRepository(name: $name, visibility: $visibility, description: $description) {\n\t\tname\n\t}\n}\n")
op.Var("name", name)
diff --git a/srht/hgsrht/operations.graphql b/srht/hgsrht/operations.graphql
index 9c739b9..2d03ddb 100644
--- a/srht/hgsrht/operations.graphql
+++ b/srht/hgsrht/operations.graphql
@@ -47,6 +47,15 @@ query userWebhooks {
}
}
+query completeUserWebhookId {
+ userWebhooks {
+ results {
+ id
+ url
+ }
+ }
+}
+
mutation createRepository(
$name: String!
$visibility: Visibility!
--
2.37.0
[PATCH 5/5] todo: Implement user-webhook ID completion
---
srht/todosrht/gql.go | 9 +++++++++
srht/todosrht/operations.graphql | 9 +++++++++
todo.go | 20 +++++++++++++++++++-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/srht/todosrht/gql.go b/srht/todosrht/gql.go
index ce701b9..91aaa41 100644
--- a/srht/todosrht/gql.go
+++ b/srht/todosrht/gql.go
@@ -847,6 +847,15 @@ func UserWebhooks(client *gqlclient.Client, ctx context.Context) (userWebhooks *
return respData.UserWebhooks, err
}
+func CompleteUserWebhookId(client *gqlclient.Client, ctx context.Context) (userWebhooks *WebhookSubscriptionCursor, err error) {
+ op := gqlclient.NewOperation("query completeUserWebhookId {\n\tuserWebhooks {\n\t\tresults {\n\t\t\tid\n\t\t\turl\n\t\t}\n\t}\n}\n")
+ var respData struct {
+ UserWebhooks *WebhookSubscriptionCursor
+ }
+ err = client.Execute(ctx, op, &respData)
+ return respData.UserWebhooks, err
+}
+
func DeleteTracker(client *gqlclient.Client, ctx context.Context, id int32) (deleteTracker *Tracker, err error) {
op := gqlclient.NewOperation("mutation deleteTracker ($id: Int!) {\n\tdeleteTracker(id: $id) {\n\t\tname\n\t}\n}\n")
op.Var("id", id)
diff --git a/srht/todosrht/operations.graphql b/srht/todosrht/operations.graphql
index 45219e4..9d87790 100644
--- a/srht/todosrht/operations.graphql
+++ b/srht/todosrht/operations.graphql
@@ -261,6 +261,15 @@ query userWebhooks {
}
}
+query completeUserWebhookId {
+ userWebhooks {
+ results {
+ id
+ url
+ }
+ }
+}
+
mutation deleteTracker($id: Int!) {
deleteTracker(id: $id) {
name
diff --git a/todo.go b/todo.go
index a1ea60f..940e565 100644
--- a/todo.go
+++ b/todo.go
@@ -752,7 +752,7 @@ func newTodoTicketWebhookDeleteCommand() *cobra.Command {
Use: "delete <ID>",
Short: "Delete a ticket webhook",
Args: cobra.ExactArgs(1),
- ValidArgsFunction: cobra.NoFileCompletions,
+ ValidArgsFunction: completeTodoUserWebhookID,
Run: run,
}
return cmd
@@ -1407,3 +1407,21 @@ func completeTodoUserWebhookEvents(cmd *cobra.Command, args []string, toComplete
}
return eventList, cobra.ShellCompDirectiveNoFileComp
}
+
+func completeTodoUserWebhookID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ ctx := cmd.Context()
+ c := createClient("todo", cmd)
+ var webhookList []string
+
+ webhooks, err := todosrht.CompleteUserWebhookId(c.Client, ctx)
+ if err != nil {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+
+ for _, webhook := range webhooks.Results {
+ s := fmt.Sprintf("%d\t%s", webhook.Id, webhook.Url)
+ webhookList = append(webhookList, s)
+ }
+
+ return webhookList, cobra.ShellCompDirectiveNoFileComp
+}
--
2.37.0
Re: [PATCH 5/5] todo: Implement user-webhook ID completion