mirror of
https://github.com/charmbracelet/glow
synced 2024-12-14 14:12:27 +00:00
Get markdown command
This commit is contained in:
parent
395ae998dd
commit
bd52d1cee4
2 changed files with 23 additions and 0 deletions
1
main.go
1
main.go
|
@ -258,4 +258,5 @@ func init() {
|
|||
|
||||
rootCmd.AddCommand(stashCmd)
|
||||
rootCmd.AddCommand(stashListCmd)
|
||||
rootCmd.AddCommand(stashGetCmd)
|
||||
}
|
||||
|
|
22
stash.go
22
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 {
|
||||
|
|
Loading…
Reference in a new issue