diff --git a/main.go b/main.go index 03dc81d..7383980 100644 --- a/main.go +++ b/main.go @@ -258,4 +258,5 @@ func init() { rootCmd.AddCommand(stashCmd) rootCmd.AddCommand(stashListCmd) + rootCmd.AddCommand(stashGetCmd) } diff --git a/stash.go b/stash.go index 0250415..424dc0b 100644 --- a/stash.go +++ b/stash.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "log" "os" + "strconv" "github.com/charmbracelet/charm" "github.com/spf13/cobra" @@ -60,6 +61,27 @@ var ( return nil }, } + + stashGetCmd = &cobra.Command{ + Use: "stash-get", + 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() + md, err := cc.GetMarkdown(id) + if err != nil { + return fmt.Errorf("error getting markdown") + } + fmt.Println(md.Body) + return nil + }, + } ) func getCharmConfig() *charm.Config {