2023-11-08 18:31:34 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/cmd/utils"
|
|
|
|
"git.faercol.me/faercol/polyculeconnect/polyculeconnect/services/app"
|
|
|
|
"github.com/dexidp/dex/storage"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var appRemoveCmd = &cobra.Command{
|
|
|
|
Use: "remove <app_client_id>",
|
|
|
|
Short: "Remove an app",
|
2024-08-10 14:27:49 +00:00
|
|
|
Long: `Remove the app with the given ID from the database.`,
|
|
|
|
Args: cobra.ExactArgs(1),
|
2023-11-08 18:31:34 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
removeApp(args[0])
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func removeApp(appID string) {
|
|
|
|
s := utils.InitStorage(utils.InitConfig(""))
|
|
|
|
|
|
|
|
if err := app.New(s).RemoveApp(appID); err != nil {
|
|
|
|
if !errors.Is(err, storage.ErrNotFound) {
|
|
|
|
utils.Failf("Failed to remove app: %s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Println("App deleted")
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
appCmd.AddCommand(appRemoveCmd)
|
|
|
|
}
|