Skip to content

Commit

Permalink
Make repo deletion message consistent with similar commands (#1593)
Browse files Browse the repository at this point in the history
Fix #1562
  • Loading branch information
eleftherias authored Nov 8, 2023
1 parent 3ffb5e4 commit 672a100
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions cmd/cli/app/repo/repo_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var repoDeleteCmd = &cobra.Command{

provider := util.GetConfigValue(viper.GetViper(), "provider", "provider", cmd, "").(string)
repoid := viper.GetString("repo-id")
format := viper.GetString("output")
name := util.GetConfigValue(viper.GetViper(), "name", "name", cmd, "").(string)

// if name is set, repo-id cannot be set
Expand All @@ -58,14 +57,6 @@ var repoDeleteCmd = &cobra.Command{
return fmt.Errorf("provider needs to be set if name is set")
}

switch format {
case formatJSON:
case formatYAML:
case formatDefault:
default:
return fmt.Errorf("invalid output format: %s", format)
}

conn, err := util.GrpcForCommand(cmd, viper.GetViper())
util.ExitNicelyOnError(err, "Error getting grpc connection")
defer conn.Close()
Expand Down Expand Up @@ -98,25 +89,10 @@ var repoDeleteCmd = &cobra.Command{
if status {
// TODO: implement this
} else {
var out string
var err error
// print result just in JSON or YAML
if format == "" || format == formatJSON {
if repoid != "" {
out, err = util.GetJsonFromProto(deletedRepoID)
} else {
out, err = util.GetJsonFromProto(deletedRepoName)
}
util.ExitNicelyOnError(err, "Error getting json from proto")
fmt.Println(out)
if repoid != "" {
cmd.Println("Successfully deleted repo with id:", deletedRepoID.RepositoryId)
} else {
if repoid != "" {
out, err = util.GetYamlFromProto(deletedRepoID)
} else {
out, err = util.GetYamlFromProto(deletedRepoName)
}
util.ExitNicelyOnError(err, "Error getting json from proto")
fmt.Println(out)
cmd.Println("Successfully deleted repo with name:", deletedRepoName.Name)
}
}
return nil
Expand All @@ -125,7 +101,6 @@ var repoDeleteCmd = &cobra.Command{

func init() {
RepoCmd.AddCommand(repoDeleteCmd)
repoDeleteCmd.Flags().StringP("output", "f", "", "Output format (json or yaml)")
repoDeleteCmd.Flags().StringP("provider", "p", "", "Name of the enrolled provider")
repoDeleteCmd.Flags().StringP("name", "n", "", "Name of the repository (owner/name format)")
repoDeleteCmd.Flags().StringP("repo-id", "r", "", "ID of the repo to delete")
Expand Down

0 comments on commit 672a100

Please sign in to comment.