Skip to content

Commit 552d80e

Browse files
author
Raphaël Benitte
committed
Add note removal functions and commands
1 parent 0424203 commit 552d80e

9 files changed

+518
-12
lines changed

README.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,18 @@ for more info.
365365
- [glc rm](#glc-rm) *Remove resource*
366366
- [glc rm alias](#glc-rm-alias) *Remove resource alias*
367367
- [glc rm group](#glc-rm-group) *Remove group*
368+
- [glc rm group-epic-note](#glc-rm-group-epic-note) *Remove group epic note*
368369
- [glc rm group-var](#glc-rm-group-var) *Remove a group's variable*
369370
- [glc rm project](#glc-rm-project) *Remove project*
370371
- [glc rm project-badge](#glc-rm-project-badge) *Remove project badge*
371372
- [glc rm project-branch](#glc-rm-project-branch) *Remove project branch*
372373
- [glc rm project-environment](#glc-rm-project-environment) *Remove project environment*
373374
- [glc rm project-hook](#glc-rm-project-hook) *Remove project hook*
375+
- [glc rm project-issue-note](#glc-rm-project-issue-note) *Remove project issue note*
376+
- [glc rm project-merge-request-note](#glc-rm-project-merge-request-note) *Remove project merge request note*
374377
- [glc rm project-merged-branches](#glc-rm-project-merged-branches) *Remove project merged branches*
375378
- [glc rm project-protected-branch](#glc-rm-project-protected-branch) *Unprotect project branch*
379+
- [glc rm project-snippet-note](#glc-rm-project-snippet-note) *Remove project snippet note*
376380
- [glc rm project-star](#glc-rm-project-star) *Unstars a given project*
377381
- [glc rm project-var](#glc-rm-project-var) *Remove a project's variable*
378382
- [glc version](#glc-version) *Print the version number of glc*
@@ -2962,14 +2966,18 @@ Remove resource
29622966

29632967
- [glc rm alias](#glc-rm-alias) *Remove resource alias*
29642968
- [glc rm group](#glc-rm-group) *Remove group*
2969+
- [glc rm group-epic-note](#glc-rm-group-epic-note) *Remove group epic note*
29652970
- [glc rm group-var](#glc-rm-group-var) *Remove a group's variable*
29662971
- [glc rm project](#glc-rm-project) *Remove project*
29672972
- [glc rm project-badge](#glc-rm-project-badge) *Remove project badge*
29682973
- [glc rm project-branch](#glc-rm-project-branch) *Remove project branch*
29692974
- [glc rm project-environment](#glc-rm-project-environment) *Remove project environment*
29702975
- [glc rm project-hook](#glc-rm-project-hook) *Remove project hook*
2976+
- [glc rm project-issue-note](#glc-rm-project-issue-note) *Remove project issue note*
2977+
- [glc rm project-merge-request-note](#glc-rm-project-merge-request-note) *Remove project merge request note*
29712978
- [glc rm project-merged-branches](#glc-rm-project-merged-branches) *Remove project merged branches*
29722979
- [glc rm project-protected-branch](#glc-rm-project-protected-branch) *Unprotect project branch*
2980+
- [glc rm project-snippet-note](#glc-rm-project-snippet-note) *Remove project snippet note*
29732981
- [glc rm project-star](#glc-rm-project-star) *Unstars a given project*
29742982
- [glc rm project-var](#glc-rm-project-var) *Remove a project's variable*
29752983

@@ -3053,6 +3061,45 @@ glc rm group GROUP_ID [flags]
30533061

30543062

30553063

3064+
#### glc rm group-epic-note
3065+
3066+
Remove group epic note
3067+
3068+
##### Synopsis
3069+
3070+
Remove group epic note
3071+
3072+
```
3073+
glc rm group-epic-note GROUP_ID EPIC_ID NOTE_ID [flags]
3074+
```
3075+
3076+
##### Options
3077+
3078+
```
3079+
-h, --help help for group-epic-note
3080+
```
3081+
3082+
##### Options inherited from parent commands
3083+
3084+
```
3085+
-a, --alias string Use resource alias
3086+
-c, --config string Path to configuration file (default ".glc.yml")
3087+
--host string GitLab host
3088+
-i, --interactive enable interactive mode when applicable (eg. creation, pagination)
3089+
--no-color disable color output
3090+
-o, --output-destination string Output result to file if specified
3091+
-f, --output-format string Output format, must be one of 'text', 'json', 'yaml'
3092+
--silent silent mode
3093+
-v, --verbose verbose output
3094+
-y, --yes Do not ask for confirmation
3095+
```
3096+
3097+
##### See also
3098+
3099+
- [glc rm](#glc-rm) *Remove resource*
3100+
3101+
3102+
30563103
#### glc rm group-var
30573104

30583105
Remove a group's variable
@@ -3287,6 +3334,84 @@ glc rm project-hook PROJECT_ID HOOK_ID [flags]
32873334

32883335

32893336

3337+
#### glc rm project-issue-note
3338+
3339+
Remove project issue note
3340+
3341+
##### Synopsis
3342+
3343+
Remove project issue note
3344+
3345+
```
3346+
glc rm project-issue-note PROJECT_ID ISSUE_IID NOTE_ID [flags]
3347+
```
3348+
3349+
##### Options
3350+
3351+
```
3352+
-h, --help help for project-issue-note
3353+
```
3354+
3355+
##### Options inherited from parent commands
3356+
3357+
```
3358+
-a, --alias string Use resource alias
3359+
-c, --config string Path to configuration file (default ".glc.yml")
3360+
--host string GitLab host
3361+
-i, --interactive enable interactive mode when applicable (eg. creation, pagination)
3362+
--no-color disable color output
3363+
-o, --output-destination string Output result to file if specified
3364+
-f, --output-format string Output format, must be one of 'text', 'json', 'yaml'
3365+
--silent silent mode
3366+
-v, --verbose verbose output
3367+
-y, --yes Do not ask for confirmation
3368+
```
3369+
3370+
##### See also
3371+
3372+
- [glc rm](#glc-rm) *Remove resource*
3373+
3374+
3375+
3376+
#### glc rm project-merge-request-note
3377+
3378+
Remove project merge request note
3379+
3380+
##### Synopsis
3381+
3382+
Remove project merge request note
3383+
3384+
```
3385+
glc rm project-merge-request-note PROJECT_ID MERGE_REQUEST_IID NOTE_ID [flags]
3386+
```
3387+
3388+
##### Options
3389+
3390+
```
3391+
-h, --help help for project-merge-request-note
3392+
```
3393+
3394+
##### Options inherited from parent commands
3395+
3396+
```
3397+
-a, --alias string Use resource alias
3398+
-c, --config string Path to configuration file (default ".glc.yml")
3399+
--host string GitLab host
3400+
-i, --interactive enable interactive mode when applicable (eg. creation, pagination)
3401+
--no-color disable color output
3402+
-o, --output-destination string Output result to file if specified
3403+
-f, --output-format string Output format, must be one of 'text', 'json', 'yaml'
3404+
--silent silent mode
3405+
-v, --verbose verbose output
3406+
-y, --yes Do not ask for confirmation
3407+
```
3408+
3409+
##### See also
3410+
3411+
- [glc rm](#glc-rm) *Remove resource*
3412+
3413+
3414+
32903415
#### glc rm project-merged-branches
32913416

32923417
Remove project merged branches
@@ -3365,6 +3490,45 @@ glc rm project-protected-branch PROJECT_ID BRANCH_NAME [flags]
33653490

33663491

33673492

3493+
#### glc rm project-snippet-note
3494+
3495+
Remove project snippet note
3496+
3497+
##### Synopsis
3498+
3499+
Remove project snippet note
3500+
3501+
```
3502+
glc rm project-snippet-note PROJECT_ID SNIPPET_ID NOTE_ID [flags]
3503+
```
3504+
3505+
##### Options
3506+
3507+
```
3508+
-h, --help help for project-snippet-note
3509+
```
3510+
3511+
##### Options inherited from parent commands
3512+
3513+
```
3514+
-a, --alias string Use resource alias
3515+
-c, --config string Path to configuration file (default ".glc.yml")
3516+
--host string GitLab host
3517+
-i, --interactive enable interactive mode when applicable (eg. creation, pagination)
3518+
--no-color disable color output
3519+
-o, --output-destination string Output result to file if specified
3520+
-f, --output-format string Output format, must be one of 'text', 'json', 'yaml'
3521+
--silent silent mode
3522+
-v, --verbose verbose output
3523+
-y, --yes Do not ask for confirmation
3524+
```
3525+
3526+
##### See also
3527+
3528+
- [glc rm](#glc-rm) *Remove resource*
3529+
3530+
3531+
33683532
#### glc rm project-star
33693533

33703534
Unstars a given project

cli/cmd/resources.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var resources = map[string][]string{
2424
"project-issue": {"project_id", "issue_iid"},
2525
"project-issue-note": {"project_id", "issue_iid", "note_id"},
2626
"project-snippet": {"project_id", "snippet_id"},
27+
"project-snippet-note": {"project_id", "snippet_id", "note_id"},
2728
"group-epic": {"group_id", "epic_id"},
2829
"group-epic-note": {"group_id", "epic_id", "note_id"},
2930
}

cli/cmd/rm_group_epic_note_cmd.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/fatih/color"
7+
"github.com/spf13/cobra"
8+
"strconv"
9+
)
10+
11+
func init() {
12+
rmCmd.AddCommand(rmGroupEpicNoteCmd)
13+
}
14+
15+
var rmGroupEpicNoteCmd = &cobra.Command{
16+
Use: resourceCmd("group-epic-note", "group-epic-note"),
17+
Aliases: []string{"epic-note"},
18+
Short: "Remove group epic note",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
ids, err := config.aliasIdsOrArgs(currentAlias, "group-epic-note", args)
21+
if err != nil {
22+
return err
23+
}
24+
25+
epicId, err := strconv.Atoi(ids["epic_id"])
26+
if err != nil {
27+
return err
28+
}
29+
30+
noteId, err := strconv.Atoi(ids["note_id"])
31+
if err != nil {
32+
return err
33+
}
34+
35+
color.Yellow("Removing group epic note (group id: %s, epic id: %d, note id: %d)…", ids["group_id"], epicId, noteId)
36+
37+
confirmed := confirmAction(
38+
fmt.Sprintf("Are you sure you want to remove group %s epic %d note %d?", ids["group_id"], epicId, noteId),
39+
"aborted group epic note removal",
40+
autoConfirmRemoval,
41+
)
42+
if !confirmed {
43+
return nil
44+
}
45+
46+
loader.Start()
47+
meta, err := client.RemoveGroupEpicNote(ids["group_id"], epicId, noteId)
48+
loader.Stop()
49+
if err != nil {
50+
return err
51+
}
52+
53+
color.Green("✔ Successfully removed note: %d", noteId)
54+
55+
printMeta(meta, false)
56+
57+
return nil
58+
},
59+
}

cli/cmd/rm_project_issue_note_cmd.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/fatih/color"
7+
"github.com/spf13/cobra"
8+
"strconv"
9+
)
10+
11+
func init() {
12+
rmCmd.AddCommand(rmProjectIssueNoteCmd)
13+
}
14+
15+
var rmProjectIssueNoteCmd = &cobra.Command{
16+
Use: resourceCmd("project-issue-note", "project-issue-note"),
17+
Aliases: []string{"issue-note"},
18+
Short: "Remove project issue note",
19+
RunE: func(cmd *cobra.Command, args []string) error {
20+
ids, err := config.aliasIdsOrArgs(currentAlias, "project-issue-note", args)
21+
if err != nil {
22+
return err
23+
}
24+
25+
issueIid, err := strconv.Atoi(ids["issue_iid"])
26+
if err != nil {
27+
return err
28+
}
29+
30+
noteId, err := strconv.Atoi(ids["note_id"])
31+
if err != nil {
32+
return err
33+
}
34+
35+
color.Yellow("Removing project issue note (project id: %s, issue iid: %d, note id: %d)…", ids["project_id"], issueIid, noteId)
36+
37+
confirmed := confirmAction(
38+
fmt.Sprintf("Are you sure you want to remove project %s issue %d note %d?", ids["project_id"], issueIid, noteId),
39+
"aborted project issue note removal",
40+
autoConfirmRemoval,
41+
)
42+
if !confirmed {
43+
return nil
44+
}
45+
46+
loader.Start()
47+
meta, err := client.RemoveProjectIssueNote(ids["project_id"], issueIid, noteId)
48+
loader.Stop()
49+
if err != nil {
50+
return err
51+
}
52+
53+
color.Green("✔ Successfully removed note: %d", noteId)
54+
55+
printMeta(meta, false)
56+
57+
return nil
58+
},
59+
}

0 commit comments

Comments
 (0)