git-project-manager/cmd/alias_delete.go
2023-12-08 17:06:09 -05:00

35 lines
783 B
Go

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