Delete from stash command

This commit is contained in:
Toby Padilla 2020-04-23 18:02:59 -05:00 committed by Christian Muehlhaeuser
commit 4792345f31
2 changed files with 22 additions and 3 deletions

View file

@ -256,7 +256,5 @@ func init() {
rootCmd.Flags().BoolVarP(&forceKey, "force-key", "f", false, "for the use of the SSH key on disk (that is, ignore ssh-agent)")
stashCmd.PersistentFlags().StringVarP(&memo, "memo", "m", "", "memo/note for stashing")
rootCmd.AddCommand(stashCmd)
rootCmd.AddCommand(stashListCmd)
rootCmd.AddCommand(stashGetCmd)
rootCmd.AddCommand(stashCmd, stashListCmd, stashGetCmd, stashDeleteCmd)
}

View file

@ -82,6 +82,27 @@ var (
return nil
},
}
stashDeleteCmd = &cobra.Command{
Use: "stash-delete",
Hidden: false,
Short: "get a stashed markdown by id",
Long: "",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
id, err := strconv.Atoi(args[0])
if err != nil {
return fmt.Errorf("invalid markdown id")
}
cc := initCharmClient()
err = cc.DeleteMarkdown(id)
if err != nil {
return fmt.Errorf("error deleting markdown")
}
fmt.Println("Deleted!")
return nil
},
}
)
func getCharmConfig() *charm.Config {