Skip to content

Commit 02db90e

Browse files
committed
fix(perms): print perm message
1 parent b5bdd62 commit 02db90e

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

cmd/perms.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ func (d *DryccCmd) PermCreate(codename, uniqueid, username string) error {
4949
if err != nil {
5050
return err
5151
}
52-
d.Printf("Adding %s to %s:%s collaborators... ", username, codename, uniqueid)
52+
d.Printf("Adding user %s as a collaborator for %s %s... ", username, codename, uniqueid)
53+
quit := progress(d.WOut)
5354
err = perms.Create(s.Client, codename, uniqueid, username)
54-
55+
quit <- true
56+
<-quit
5557
if d.checkAPICompatibility(s.Client, err) != nil {
5658
return err
5759
}
@@ -67,9 +69,11 @@ func (d *DryccCmd) PermDelete(userPermID uint64) error {
6769
if err != nil {
6870
return err
6971
}
70-
d.Printf("Removing user perm with id %d... ", userPermID)
72+
d.Printf("Removing user permission... ")
73+
quit := progress(d.WOut)
7174
err = perms.Delete(s.Client, fmt.Sprintf("%d", userPermID))
72-
75+
quit <- true
76+
<-quit
7377
if d.checkAPICompatibility(s.Client, err) != nil {
7478
return err
7579
}

cmd/perms_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestCreateUserPerm(t *testing.T) {
133133
assert.NoError(t, err)
134134
assert.Equal(t,
135135
testutil.StripProgress(b.String()),
136-
"Adding test-user to use_app:lorem-ipsum collaborators... done\n", "output")
136+
"Adding user test-user as a collaborator for use_app lorem-ipsum... done\n", "output")
137137
}
138138

139139
func TestDeleteUserPerm(t *testing.T) {
@@ -168,5 +168,5 @@ func TestDeleteUserPerm(t *testing.T) {
168168
assert.NoError(t, err)
169169
assert.Equal(t,
170170
testutil.StripProgress(b.String()),
171-
"Removing user perm with id 1... done\n", "output")
171+
"Removing user permission... done\n", "output")
172172
}

cmd/update.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ import (
1414
const WorkflowCliURL = "https://www.drycc.cc/workflow-cli.txt"
1515

1616
func (d *DryccCmd) latestVersion() (string, string, error) {
17-
d.Print("Get the latest version of workflow cli... ")
1817
quit := progress(d.WOut)
1918
resp, err := http.Get(WorkflowCliURL)
2019
quit <- true
2120
<-quit
2221
if err != nil {
2322
return "", "", err
2423
}
25-
d.Println("done")
2624

2725
defer resp.Body.Close()
2826
body, err := io.ReadAll(resp.Body)
@@ -34,8 +32,7 @@ func (d *DryccCmd) latestVersion() (string, string, error) {
3432
for _, url := range strings.Split(string(body), "\n") {
3533
if strings.HasSuffix(url, suffix) {
3634
names := strings.Split(url, "/")
37-
name := names[len(names)-1]
38-
version := strings.ReplaceAll(strings.ReplaceAll(name, suffix, ""), prefix, "")
35+
version := strings.ReplaceAll(strings.ReplaceAll(names[len(names)-1], suffix, ""), prefix, "")
3936
return version, url, nil
4037
}
4138
}

drycc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Options:
4242
4343
Auth commands, use 'drycc help auth' to learn more:
4444
45-
register register a new user with a controller
4645
login login to a controller
4746
logout logout from the current controller
4847

parser/perms.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ func Perms(argv []string, cmdr cmd.Commander) error {
1212
usage := `
1313
Valid commands for perms:
1414
15-
perms:codes list all policy codenames
16-
perms:list list all user permission for objects
17-
perms:create create a user permission for objects
18-
perms:delete delete a user permission for objects
15+
perms:codes list all policy codename
16+
perms:list list all user permission
17+
perms:create create a user permission
18+
perms:delete delete a user permission
1919
2020
Use 'drycc help perms:[command]' to learn more.
2121
`
@@ -46,7 +46,7 @@ Use 'drycc help perms:[command]' to learn more.
4646

4747
func permsCodes(argv []string, cmdr cmd.Commander) error {
4848
usage := `
49-
List all object policy codenames.
49+
List all policy codename.
5050
5151
Usage: drycc perms:codes [options]
5252
@@ -72,7 +72,7 @@ Options:
7272

7373
func permsList(argv []string, cmdr cmd.Commander) error {
7474
usage := `
75-
List all user permission for objects
75+
List all user permission.
7676
7777
Usage: drycc perms:list [options]
7878
@@ -101,7 +101,7 @@ Options:
101101

102102
func permCreate(argv []string, cmdr cmd.Commander) error {
103103
usage := `
104-
Gives another user permission to use an object.
104+
Create a user permission.
105105
106106
Usage: drycc perms:create <username> <codename> <uniqueid>
107107
@@ -129,7 +129,7 @@ Arguments:
129129

130130
func permDelete(argv []string, cmdr cmd.Commander) error {
131131
usage := `
132-
Revokes another user's permission to use an object.
132+
Delete a user permission.
133133
134134
Usage: drycc perms:delete <id>
135135

0 commit comments

Comments
 (0)