mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 14:59:09 +00:00
add folder commands
This commit is contained in:
parent
b0303103da
commit
1b129332ae
12 changed files with 432 additions and 2 deletions
52
folder/get.go
Normal file
52
folder/get.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package folder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/speatzle/go-passbolt-cli/util"
|
||||
"github.com/speatzle/go-passbolt/helper"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// FolderGetCmd Gets a Passbolt Folder
|
||||
var FolderGetCmd = &cobra.Command{
|
||||
Use: "folder",
|
||||
Short: "Gets a Passbolt Folder",
|
||||
Long: `Gets a Passbolt Folder`,
|
||||
RunE: FolderGet,
|
||||
}
|
||||
|
||||
func init() {
|
||||
FolderGetCmd.Flags().String("id", "", "id of Folder to Get")
|
||||
|
||||
FolderGetCmd.MarkFlagRequired("id")
|
||||
}
|
||||
|
||||
func FolderGet(cmd *cobra.Command, args []string) error {
|
||||
id, err := cmd.Flags().GetString("id")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx := util.GetContext()
|
||||
|
||||
client, err := util.GetClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer client.Logout(context.TODO())
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
folderParentID, name, err := helper.GetFolder(
|
||||
ctx,
|
||||
client,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Getting Folder: %w", err)
|
||||
}
|
||||
fmt.Printf("FolderParentID: %v\n", folderParentID)
|
||||
fmt.Printf("Name: %v\n", name)
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue