mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-15 03:58:21 +00:00
Add CreatedTimestamp and ModifiedTimestamp Columns to list commands
This commit is contained in:
parent
423dfb020c
commit
d142f14ccc
4 changed files with 24 additions and 4 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alessio/shellescape"
|
"github.com/alessio/shellescape"
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
|
@ -26,7 +27,7 @@ func init() {
|
||||||
FolderListCmd.Flags().StringP("search", "s", "", "Folders that have this in the Name")
|
FolderListCmd.Flags().StringP("search", "s", "", "Folders that have this in the Name")
|
||||||
FolderListCmd.Flags().StringArrayP("folder", "f", []string{}, "Folders that are in this Folder")
|
FolderListCmd.Flags().StringArrayP("folder", "f", []string{}, "Folders that are in this Folder")
|
||||||
FolderListCmd.Flags().StringArrayP("group", "g", []string{}, "Folders that are shared with group")
|
FolderListCmd.Flags().StringArrayP("group", "g", []string{}, "Folders that are shared with group")
|
||||||
FolderListCmd.Flags().StringArrayP("column", "c", []string{"ID", "FolderParentID", "Name"}, "Columns to return, possible Columns:\nID, FolderParentID, Name")
|
FolderListCmd.Flags().StringArrayP("column", "c", []string{"ID", "FolderParentID", "Name"}, "Columns to return, possible Columns:\nID, FolderParentID, Name, CreatedTimestamp, ModifiedTimestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func FolderList(cmd *cobra.Command, args []string) error {
|
func FolderList(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -75,6 +76,10 @@ func FolderList(cmd *cobra.Command, args []string) error {
|
||||||
entry[i] = folder.FolderParentID
|
entry[i] = folder.FolderParentID
|
||||||
case "name":
|
case "name":
|
||||||
entry[i] = shellescape.StripUnsafe(folder.Name)
|
entry[i] = shellescape.StripUnsafe(folder.Name)
|
||||||
|
case "createdtimestamp":
|
||||||
|
entry[i] = folder.Created.Format(time.RFC3339)
|
||||||
|
case "modifiedtimestamp":
|
||||||
|
entry[i] = folder.Modified.Format(time.RFC3339)
|
||||||
default:
|
default:
|
||||||
cmd.SilenceUsage = false
|
cmd.SilenceUsage = false
|
||||||
return fmt.Errorf("Unknown Column: %v", columns[i])
|
return fmt.Errorf("Unknown Column: %v", columns[i])
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alessio/shellescape"
|
"github.com/alessio/shellescape"
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
|
@ -26,7 +27,7 @@ func init() {
|
||||||
GroupListCmd.Flags().StringArrayP("user", "u", []string{}, "Groups that are shared with group")
|
GroupListCmd.Flags().StringArrayP("user", "u", []string{}, "Groups that are shared with group")
|
||||||
GroupListCmd.Flags().StringArrayP("manager", "m", []string{}, "Groups that are in folder")
|
GroupListCmd.Flags().StringArrayP("manager", "m", []string{}, "Groups that are in folder")
|
||||||
|
|
||||||
GroupListCmd.Flags().StringArrayP("column", "c", []string{"ID", "Name"}, "Columns to return, possible Columns:\nID, Name")
|
GroupListCmd.Flags().StringArrayP("column", "c", []string{"ID", "Name"}, "Columns to return, possible Columns:\nID, Name, CreatedTimestamp, ModifiedTimestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GroupList(cmd *cobra.Command, args []string) error {
|
func GroupList(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -73,6 +74,10 @@ func GroupList(cmd *cobra.Command, args []string) error {
|
||||||
entry[i] = group.ID
|
entry[i] = group.ID
|
||||||
case "name":
|
case "name":
|
||||||
entry[i] = shellescape.StripUnsafe(group.Name)
|
entry[i] = shellescape.StripUnsafe(group.Name)
|
||||||
|
case "createdtimestamp":
|
||||||
|
entry[i] = group.Created.Format(time.RFC3339)
|
||||||
|
case "modifiedtimestamp":
|
||||||
|
entry[i] = group.Modified.Format(time.RFC3339)
|
||||||
default:
|
default:
|
||||||
cmd.SilenceUsage = false
|
cmd.SilenceUsage = false
|
||||||
return fmt.Errorf("Unknown Column: %v", columns[i])
|
return fmt.Errorf("Unknown Column: %v", columns[i])
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alessio/shellescape"
|
"github.com/alessio/shellescape"
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
|
@ -30,7 +31,7 @@ func init() {
|
||||||
ResourceListCmd.Flags().StringP("group", "g", "", "Resources that are shared with group")
|
ResourceListCmd.Flags().StringP("group", "g", "", "Resources that are shared with group")
|
||||||
ResourceListCmd.Flags().StringArrayP("folder", "f", []string{}, "Resources that are in folder")
|
ResourceListCmd.Flags().StringArrayP("folder", "f", []string{}, "Resources that are in folder")
|
||||||
|
|
||||||
ResourceListCmd.Flags().StringArrayP("column", "c", []string{"ID", "FolderParentID", "Name", "Username", "URI"}, "Columns to return, possible Columns:\nID, FolderParentID, Name, Username, URI, Password, Description")
|
ResourceListCmd.Flags().StringArrayP("column", "c", []string{"ID", "FolderParentID", "Name", "Username", "URI"}, "Columns to return, possible Columns:\nID, FolderParentID, Name, Username, URI, Password, Description, CreatedTimestamp, ModifiedTimestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceList(cmd *cobra.Command, args []string) error {
|
func ResourceList(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -105,6 +106,10 @@ func ResourceList(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("Get Resource %w", err)
|
return fmt.Errorf("Get Resource %w", err)
|
||||||
}
|
}
|
||||||
entry[i] = shellescape.StripUnsafe(desc)
|
entry[i] = shellescape.StripUnsafe(desc)
|
||||||
|
case "createdtimestamp":
|
||||||
|
entry[i] = resource.Created.Format(time.RFC3339)
|
||||||
|
case "modifiedtimestamp":
|
||||||
|
entry[i] = resource.Modified.Format(time.RFC3339)
|
||||||
default:
|
default:
|
||||||
cmd.SilenceUsage = false
|
cmd.SilenceUsage = false
|
||||||
return fmt.Errorf("Unknown Column: %v", columns[i])
|
return fmt.Errorf("Unknown Column: %v", columns[i])
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alessio/shellescape"
|
"github.com/alessio/shellescape"
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
|
@ -29,7 +30,7 @@ func init() {
|
||||||
UserListCmd.Flags().StringP("search", "s", "", "Search for Users")
|
UserListCmd.Flags().StringP("search", "s", "", "Search for Users")
|
||||||
UserListCmd.Flags().BoolP("admin", "a", false, "Only show Admins")
|
UserListCmd.Flags().BoolP("admin", "a", false, "Only show Admins")
|
||||||
|
|
||||||
UserListCmd.Flags().StringArrayP("column", "c", []string{"ID", "Username", "FirstName", "LastName", "Role"}, "Columns to return, possible Columns:\nID, Username, FirstName, LastName, Role")
|
UserListCmd.Flags().StringArrayP("column", "c", []string{"ID", "Username", "FirstName", "LastName", "Role"}, "Columns to return, possible Columns:\nID, Username, FirstName, LastName, Role, CreatedTimestamp, ModifiedTimestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserList(cmd *cobra.Command, args []string) error {
|
func UserList(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -92,6 +93,10 @@ func UserList(cmd *cobra.Command, args []string) error {
|
||||||
entry[i] = shellescape.StripUnsafe(user.Profile.LastName)
|
entry[i] = shellescape.StripUnsafe(user.Profile.LastName)
|
||||||
case "role":
|
case "role":
|
||||||
entry[i] = shellescape.StripUnsafe(user.Role.Name)
|
entry[i] = shellescape.StripUnsafe(user.Role.Name)
|
||||||
|
case "createdtimestamp":
|
||||||
|
entry[i] = user.Created.Format(time.RFC3339)
|
||||||
|
case "modifiedtimestamp":
|
||||||
|
entry[i] = user.Modified.Format(time.RFC3339)
|
||||||
default:
|
default:
|
||||||
cmd.SilenceUsage = false
|
cmd.SilenceUsage = false
|
||||||
return fmt.Errorf("Unknown Column: %v", columns[i])
|
return fmt.Errorf("Unknown Column: %v", columns[i])
|
||||||
|
|
Loading…
Add table
Reference in a new issue