git-project-manager/cmd/alias_delete.go

35 lines
783 B
Go
Raw Normal View History

2023-12-08 21:52:26 +00:00
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/gitlab"
)
2023-12-08 22:06:09 +00:00
var aliasDeleteCmd = &cobra.Command{
Use: "delete [fuzzy project or alias]",
Short: "Delete a project alias",
Long: aliasDeleteCmdLong,
Run: runDeleteAliasCmd,
2023-12-08 21:52:26 +00:00
}
2023-12-08 22:06:09 +00:00
func runDeleteAliasCmd(cmd *cobra.Command, args []string) {
2023-12-08 21:52:26 +00:00
var project *gitlab.Project
2023-12-08 22:06:09 +00:00
if len(args) > 0 {
project = fzfFindProject(args[0])
2023-12-08 21:52:26 +00:00
} else {
2023-12-08 22:06:09 +00:00
project, _ = fzfProject(cmd.Context())
2023-12-08 21:52:26 +00:00
}
2023-12-08 22:06:09 +00:00
fmt.Println(project.String())
2023-12-08 21:52:26 +00:00
}
func init() {
2023-12-08 22:06:09 +00:00
aliasCmd.AddCommand(aliasDeleteCmd)
aliasDeleteCmd.PersistentFlags().Int("projectID", 0, "Specify a project by ID")
viper.BindPFlag("alias.delete.projectID", aliasDeleteCmd.Flag("projectID"))
2023-12-08 21:52:26 +00:00
}