diff --git a/main.go b/main.go index a4782d5..03dc81d 100644 --- a/main.go +++ b/main.go @@ -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) } diff --git a/stash.go b/stash.go index 92aea4d..0250415 100644 --- a/stash.go +++ b/stash.go @@ -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 {