Skip to content

Commit 21ffa10

Browse files
author
JojiiOfficial
committed
close #21
1 parent fb84793 commit 21ffa10

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed

Command.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func runCommand(parsed string, commandData *commands.CommandData) {
8080
commandData.EditFile(*fileEditID)
8181

8282
// -- Attributes commands
83+
// List Tags
84+
case tagListCmd.FullCommand():
85+
commandData.ListAttributes(libdm.TagAttribute)
86+
8387
// Update tag
8488
case tagUpdateCmd.FullCommand():
8589
commands.UpdateAttribute(commandData, libdm.TagAttribute, *tagUpdateName, *tagUpdateNewName)
@@ -88,6 +92,10 @@ func runCommand(parsed string, commandData *commands.CommandData) {
8892
case tagDeleteCmd.FullCommand():
8993
commands.DeleteAttribute(commandData, libdm.TagAttribute, *tagDeleteName)
9094

95+
// List Groups
96+
case groupListCmd.FullCommand():
97+
commandData.ListAttributes(libdm.GroupAttribute)
98+
9199
// Update group
92100
case groupUpdateCmd.FullCommand():
93101
commands.UpdateAttribute(commandData, libdm.GroupAttribute, *groupUpdateName, *groupUpdateNewName)
@@ -171,6 +179,7 @@ func runCommand(parsed string, commandData *commands.CommandData) {
171179
case keystoreAddKeyCmd.FullCommand():
172180
commands.KeystoreAddKey(commandData, *keystoreAddKeyCmdKey, *keystoreAddKeyCmdFileID)
173181

182+
// Remove key from keystore
174183
case keystoreRemoveKeyCmd.FullCommand():
175184
commands.KeystoreRemoveKey(commandData, *keystoreRemoveKeyCmdID)
176185

commands/Attribute.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,32 @@ func DeleteAttribute(cData *CommandData, attribute libdm.Attribute, name string)
2828

2929
fmt.Printf("The attribute has been %s\n", color.HiGreenString("successfully deleted"))
3030
}
31+
32+
// ListAttributes lists attributes in a namespace
33+
func (cData *CommandData) ListAttributes(attribute libdm.Attribute) {
34+
var attributes []libdm.Attribute
35+
var err error
36+
37+
switch attribute {
38+
case libdm.GroupAttribute:
39+
attributes, err = cData.LibDM.GetGroups(cData.FileAttributes.Namespace)
40+
case libdm.TagAttribute:
41+
attributes, err = cData.LibDM.GetTags(cData.FileAttributes.Namespace)
42+
default:
43+
return
44+
}
45+
46+
if err != nil {
47+
printError("listing attribute", err.Error())
48+
return
49+
}
50+
51+
if len(attributes) == 0 {
52+
fmt.Println("No attributes found")
53+
return
54+
}
55+
56+
for i := range attributes {
57+
fmt.Println(attributes[i])
58+
}
59+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.14
55
replace github.com/gosuri/uiprogress v0.0.1 => github.com/JojiiOfficial/uiprogress v1.0.5
66

77
require (
8-
github.com/DataManager-Go/libdatamanager v1.1.16
8+
github.com/DataManager-Go/libdatamanager v1.1.18
99
github.com/DataManager-Go/libdatamanager/config v0.0.0-20200413125811-cf32dc70af40
1010
github.com/JojiiOfficial/configService v0.0.0-20200219132202-6e71512e2e28
1111
github.com/JojiiOfficial/gaw v1.2.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
33
github.com/DataManager-Go/libdatamanager v1.0.10/go.mod h1:iLQrv9tvUkcx9nA+x51eUR9juV0JgIOnFrhPISxWWUE=
44
github.com/DataManager-Go/libdatamanager v1.1.16 h1:HIHQQJeQRAoxyJGCb0kRRdD3FqZNyNFTneW6NxXma9M=
55
github.com/DataManager-Go/libdatamanager v1.1.16/go.mod h1:s2ywdIZpWEfgxJ7iMtCOdLCNaHVnO8dr7e9cE2NzgL4=
6+
github.com/DataManager-Go/libdatamanager v1.1.18 h1:GZsgMas8Tx4q9buU/z0b5VDMIV0tOVKGDo1cbkS7msM=
7+
github.com/DataManager-Go/libdatamanager v1.1.18/go.mod h1:s2ywdIZpWEfgxJ7iMtCOdLCNaHVnO8dr7e9cE2NzgL4=
68
github.com/DataManager-Go/libdatamanager/config v0.0.0-20200413125811-cf32dc70af40 h1:prAklwiqvcLkXnjm9Zl7H3IUW3nnB6U0ebrNuMacjZ4=
79
github.com/DataManager-Go/libdatamanager/config v0.0.0-20200413125811-cf32dc70af40/go.mod h1:RfoOPe8dQgubuBUmtqEYu1Ny0fT+htZH/ArrEl0dcHQ=
810
github.com/JojiiOfficial/configService v0.0.0-20200219132202-6e71512e2e28 h1:nYoIExG+Z/gSLS9Jbpu6lnrh+m6e9gTxQfGhanTsExE=

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ var (
185185
// ---------> Tag commands --------------------------------------
186186
tagCmd = app.Command("tag", "Do something with tags").Alias("t")
187187

188+
// -- List
189+
tagListCmd = app.Command("tags", "List existing tags").Alias("ts")
188190
// -- Delete
189191
tagDeleteCmd = tagCmd.Command("delete", "Delete a tag").Alias("rm").Alias("del")
190192
tagDeleteName = tagDeleteCmd.Arg("tagName", "Name of tag to delete").Required().String()
@@ -197,6 +199,8 @@ var (
197199
// ---------> Group commands --------------------------------------
198200
groupCmd = app.Command("group", "Do something with groups").Alias("g").Alias("gr")
199201

202+
// -- List
203+
groupListCmd = app.Command("groups", "List existing groups").Alias("gs")
200204
// -- Delete
201205
groupDeleteCmd = groupCmd.Command("delete", "Delete a group").Alias("rm").Alias("del")
202206
groupDeleteName = groupDeleteCmd.Arg("groupName", "Name of group to delete").Required().String()

0 commit comments

Comments
 (0)