From a8eb96a7a18d8187ab09a1c6092ad496bc529cd3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 10 Jan 2024 09:38:03 -0300 Subject: [PATCH 1/2] docs: --delete-older-than Signed-off-by: Carlos Alexandro Becker --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index f2aa966c..60a05e02 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,17 @@ Show the saved conversation the given title or SHA1. Deletes the saved conversation with the given title or SHA1. +`--delete-older-than=duration` + +Delete conversations older than the given duration (e.g. `10d`, `3w`, `1mo`, +`1y`). + +If the terminal is interactive, it'll first list the conversations to be deleted +and then will ask for confirmation. + +If the terminal is not interactive, or if `--quiet` is provided, it'll delete +the conversations without any confirmation. + #### Format As Markdown `-f`, `--format`, `MODS_FORMAT` From bef5df74b882a6ff99f852d66caa85945a560e51 Mon Sep 17 00:00:00 2001 From: cloudbridgeuy <127410436+cloudbridgeuy@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:55:06 -0300 Subject: [PATCH 2/2] feat: implement word wrapping for formatted output (#171) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: implement word wrapping for formatted output * style: fix lint issue --------- Co-authored-by: Guzmán Monné Co-authored-by: Carlos Alexandro Becker --- README.md | 6 ++++++ config.go | 6 ++++++ config_template.go | 2 ++ main.go | 1 + mods.go | 2 +- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60a05e02..ab93553e 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,12 @@ Backup your old settings file and reset everything to the defaults. Disables conversation saving. +#### Wrap Words + +`--word-wrap`, `MODS_WORD_WRAP` + +Wrap formatted output at specific width (default is 80) + #### HTTP Proxy `-x`, `--http-proxy`, `MODS_HTTP_PROXY` diff --git a/config.go b/config.go index 180a5f2c..477be9ea 100644 --- a/config.go +++ b/config.go @@ -34,6 +34,7 @@ var help = map[string]string{ "version": "Show version and exit.", "max-retries": "Maximum number of times to retry API calls.", "no-limit": "Turn off the client-side limit on the size of the input into the model.", + "word-wrap": "Wrap formatted output at specific width (default is 80)", "max-tokens": "Maximum number of tokens in response.", "temp": "Temperature (randomness) of results, from 0.0 to 2.0.", "topp": "TopP, an alternative to temperature that narrows response, from 0.0 to 1.0.", @@ -103,6 +104,7 @@ type Config struct { IncludePromptArgs bool `yaml:"include-prompt-args" env:"INCLUDE_PROMPT_ARGS"` IncludePrompt int `yaml:"include-prompt" env:"INCLUDE_PROMPT"` MaxRetries int `yaml:"max-retries" env:"MAX_RETRIES"` + WordWrap int `yaml:"word-wrap" env:"WORD_WRAP"` Fanciness uint `yaml:"fanciness" env:"FANCINESS"` StatusText string `yaml:"status-text" env:"STATUS_TEXT"` FormatText string `yaml:"format-text" env:"FORMAT_TEXT"` @@ -184,6 +186,10 @@ func ensureConfig() (Config, error) { return c, modsError{err, "Could not create cache directory."} } + if c.WordWrap == 0 { + c.WordWrap = 80 + } + return c, nil } diff --git a/config_template.go b/config_template.go index eba0a434..675929c6 100644 --- a/config_template.go +++ b/config_template.go @@ -16,6 +16,8 @@ temp: 1.0 topp: 1.0 # {{ index .Help "no-limit" }} no-limit: false +# {{ index .Help "word-wrap" }} +word-wrap: 80 # {{ index .Help "prompt-args" }} include-prompt-args: false # {{ index .Help "prompt" }} diff --git a/main.go b/main.go index 3a0c97ea..21aee028 100644 --- a/main.go +++ b/main.go @@ -194,6 +194,7 @@ func initFlags() { flags.IntVar(&config.MaxRetries, "max-retries", config.MaxRetries, stdoutStyles().FlagDesc.Render(help["max-retries"])) flags.BoolVar(&config.NoLimit, "no-limit", config.NoLimit, stdoutStyles().FlagDesc.Render(help["no-limit"])) flags.IntVar(&config.MaxTokens, "max-tokens", config.MaxTokens, stdoutStyles().FlagDesc.Render(help["max-tokens"])) + flags.IntVar(&config.WordWrap, "word-wrap", config.WordWrap, stdoutStyles().FlagDesc.Render(help["word-wrap"])) flags.Float32Var(&config.Temperature, "temp", config.Temperature, stdoutStyles().FlagDesc.Render(help["temp"])) flags.Float32Var(&config.TopP, "topp", config.TopP, stdoutStyles().FlagDesc.Render(help["topp"])) flags.UintVar(&config.Fanciness, "fanciness", config.Fanciness, stdoutStyles().FlagDesc.Render(help["fanciness"])) diff --git a/mods.go b/mods.go index 74ae914a..69da6695 100644 --- a/mods.go +++ b/mods.go @@ -63,7 +63,7 @@ type Mods struct { } func newMods(r *lipgloss.Renderer, cfg *Config, db *convoDB, cache *convoCache) *Mods { - gr, _ := glamour.NewTermRenderer(glamour.WithEnvironmentConfig()) + gr, _ := glamour.NewTermRenderer(glamour.WithEnvironmentConfig(), glamour.WithWordWrap(cfg.WordWrap)) vp := viewport.New(0, 0) vp.GotoBottom() return &Mods{