List stash

This commit is contained in:
Toby Padilla 2020-04-23 17:47:04 -05:00 committed by Christian Muehlhaeuser
commit 395ae998dd
2 changed files with 24 additions and 2 deletions

View file

@ -252,9 +252,10 @@ func init() {
rootCmd.Flags().StringVarP(&style, "style", "s", "auto", "style name or JSON path")
rootCmd.Flags().UintVarP(&width, "width", "w", 0, "word-wrap at width")
stashCmd.PersistentFlags().StringVarP(&identityFile, "identity", "i", "", "path to identity file (that is, an ssh private key)")
rootCmd.PersistentFlags().StringVarP(&identityFile, "identity", "i", "", "path to identity file (that is, an ssh private key)")
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")
stashCmd.Flags().BoolVarP(&forceKey, "force-key", "f", false, "for the use of the SSH key on disk (that is, ignore ssh-agent)")
rootCmd.AddCommand(stashCmd)
rootCmd.AddCommand(stashListCmd)
}

View file

@ -39,6 +39,27 @@ var (
return nil
},
}
stashListCmd = &cobra.Command{
Use: "stash-list",
Hidden: false,
Short: "list your stashed markdowns",
Long: "",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
cc := initCharmClient()
mds, err := cc.GetStash()
if err != nil {
return fmt.Errorf("error getting stash")
}
fmt.Println("ID\tNote")
fmt.Println("--\t----")
for _, md := range mds {
fmt.Printf("%d\t%s\n", md.ID, md.Note)
}
return nil
},
}
)
func getCharmConfig() *charm.Config {