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
43
folder/delete.go
Normal file
43
folder/delete.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package folder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/speatzle/go-passbolt-cli/util"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// FolderDeleteCmd Deletes a Folder
|
||||
var FolderDeleteCmd = &cobra.Command{
|
||||
Use: "folder",
|
||||
Short: "Deletes a Passbolt Folder",
|
||||
Long: `Deletes a Passbolt Folder`,
|
||||
RunE: FolderDelete,
|
||||
}
|
||||
|
||||
func FolderDelete(cmd *cobra.Command, args []string) error {
|
||||
folderID, err := cmd.Flags().GetString("id")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if folderID == "" {
|
||||
return fmt.Errorf("No ID to Delete Provided")
|
||||
}
|
||||
|
||||
ctx := util.GetContext()
|
||||
|
||||
client, err := util.GetClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer client.Logout(context.TODO())
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
client.DeleteFolder(ctx, folderID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Deleting Folder: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue