mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-21 15:44:17 +02:00
Format help and add examples to stash command
This commit is contained in:
parent
2c411a3f28
commit
805a26090f
3 changed files with 25 additions and 6 deletions
15
formatting.go
Normal file
15
formatting.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/muesli/reflow/indent"
|
||||
"github.com/muesli/reflow/wordwrap"
|
||||
)
|
||||
|
||||
const (
|
||||
wrapAt = 78
|
||||
indentAmount = 2
|
||||
)
|
||||
|
||||
func formatBlock(s string) string {
|
||||
return indent.String(wordwrap.String(s, wrapAt-indentAmount), indentAmount)
|
||||
}
|
||||
2
main.go
2
main.go
|
|
@ -17,6 +17,7 @@ import (
|
|||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/charm/ui/common"
|
||||
"github.com/charmbracelet/glamour"
|
||||
"github.com/charmbracelet/glow/ui"
|
||||
)
|
||||
|
|
@ -33,6 +34,7 @@ var (
|
|||
rootCmd = &cobra.Command{
|
||||
Use: "glow SOURCE",
|
||||
Short: "Render markdown on the CLI, with pizzazz!",
|
||||
Long: formatBlock(fmt.Sprintf("\nRender markdown on the CLI, %s!", common.Keyword("with pizzazz"))),
|
||||
SilenceErrors: false,
|
||||
SilenceUsage: false,
|
||||
TraverseChildren: true,
|
||||
|
|
|
|||
14
stash_cmd.go
14
stash_cmd.go
|
|
@ -23,11 +23,12 @@ var (
|
|||
memo string
|
||||
|
||||
stashCmd = &cobra.Command{
|
||||
Use: "stash SOURCE",
|
||||
Hidden: false,
|
||||
Short: "stash a markdown",
|
||||
Long: "",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "stash SOURCE",
|
||||
Hidden: false,
|
||||
Short: "stash a markdown",
|
||||
Long: formatBlock(fmt.Sprintf("\nSave a mardkdown file to your %s.", common.Keyword("stash"))),
|
||||
Example: formatBlock("glow stash README.md\nglow stash -m \"secret notes\" path/to/notes.md"),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
filePath := args[0]
|
||||
|
||||
|
|
@ -82,7 +83,8 @@ func initCharmClient() *charm.Client {
|
|||
cfg := getCharmConfig()
|
||||
cc, err := charm.NewClient(cfg)
|
||||
if err == charm.ErrMissingSSHAuth {
|
||||
log.Fatal("Missing ssh key. Run `ssh-keygen` to make one or set the `CHARM_SSH_KEY_PATH` env var to your private key path.")
|
||||
fmt.Println(formatBlock("We had some trouble authenticating via SSH. If this continues to happen the Charm tool may be able to help you. More info at https://github.com/charmbracelet/charm."))
|
||||
os.Exit(1)
|
||||
} else if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue