Skip to content

Commit 3563aea

Browse files
authored
Add Revision Name to Get/Delete (#6)
Add revision to get/delete
1 parent 241f9ba commit 3563aea

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

cmd/delete.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package cmd
22

33
import (
44
"fmt"
5-
5+
"net/url"
66
"github.com/MakeNowJust/heredoc"
77
"github.com/cli/go-gh/v2/pkg/api"
88
"github.com/spf13/cobra"
99
)
1010

1111
type deleteCmdFlags struct {
1212
app string
13+
revisionName string
1314
}
1415

1516
type deleteResp struct {
@@ -34,6 +35,14 @@ func init() {
3435
}
3536

3637
deleteUrl := fmt.Sprintf("runtime/%s/deployment", deleteCmdFlags.app)
38+
params := url.Values{}
39+
if deleteCmdFlags.revisionName != "" {
40+
params.Add("revision_name", deleteCmdFlags.revisionName)
41+
}
42+
if len(params) > 0 {
43+
deleteUrl += "?" + params.Encode()
44+
}
45+
3746
client, err := api.DefaultRESTClient()
3847
if err != nil {
3948
fmt.Println(err)
@@ -53,5 +62,6 @@ func init() {
5362
}
5463

5564
deleteCmd.Flags().StringVarP(&deleteCmdFlags.app, "app", "a", "", "The app to delete")
65+
deleteCmd.Flags().StringVarP(&deleteCmdFlags.revisionName, "revision-name", "r", "", "The revision name to use for the app")
5666
rootCmd.AddCommand(deleteCmd)
5767
}

cmd/get.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package cmd
22

33
import (
44
"fmt"
5-
5+
"net/url"
66
"github.com/MakeNowJust/heredoc"
77
"github.com/cli/go-gh/v2/pkg/api"
88
"github.com/spf13/cobra"
99
)
1010

1111
type getCmdFlags struct {
12-
app string
12+
app string
13+
revisionName string
1314
}
1415

1516
type serverResponse struct {
@@ -34,6 +35,14 @@ func init() {
3435
}
3536

3637
getUrl := fmt.Sprintf("runtime/%s/deployment", getCmdFlags.app)
38+
params := url.Values{}
39+
if getCmdFlags.revisionName != "" {
40+
params.Add("revision_name", getCmdFlags.revisionName)
41+
}
42+
if len(params) > 0 {
43+
getUrl += "?" + params.Encode()
44+
}
45+
3746
client, err := api.DefaultRESTClient()
3847
if err != nil {
3948
return fmt.Errorf("failed creating REST client: %v", err)
@@ -51,5 +60,6 @@ func init() {
5160
}
5261

5362
getCmd.Flags().StringVarP(&getCmdFlags.app, "app", "a", "", "The app to retrieve details for")
63+
getCmd.Flags().StringVarP(&getCmdFlags.revisionName, "revision-name", "r", "", "The revision name to use for the app")
5464
rootCmd.AddCommand(getCmd)
5565
}

0 commit comments

Comments
 (0)