diff --git a/README.md b/README.md index c6c8770..63aff2f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Capture and share your code on the command line.

- output of freeze command, haskell code block + output of freeze command, haskell code block

## Tutorial @@ -58,17 +58,19 @@ Screenshots can be customized with `--flags`. There are many different configuration options: -* [`--language`](#language): code language. -* [`--output`](#output): output file. -* [`--font.family`](#font): font family. -* [`--font.size`](#font): font size. -* [`--line-height`](#font): line height. -* [`--radius`](#corner-radius): add corner radius. -* [`--window`](#window): show window controls. -* [`--border`](#border): add a border to the window. -* [`--padding`](#padding): terminal padding. -* [`--margin`](#margin): window margin. -* [`--shadow`](#shadow): add a shadow to the window. +* [`-l, --language`](#language): code language. +* [`-t, --theme`](#theme): theme to use. +* [`-o, --output`](#output): output file. +* [`-r, --radius`](#corner-radius): add corner radius. +* [`-w, --window`](#window): show window controls. +* [`-b, --border`](#border): add a border to the window. +* [`-p, --padding`](#padding): terminal padding. +* [`-m, --margin`](#margin): window margin. +* [`-s, --shadow`](#shadow): add a shadow to the window. +* [` --font.family`](#font): font family. +* [` --font.size`](#font): font size. +* [` --line-height`](#font): line height. + ### Language @@ -82,6 +84,8 @@ cat artichoke.hs | freeze --language haskell
output of freeze command, haskell code block +### Theme + ### Output Change the output file location, defaults to `out.svg` or stdout if piped. This diff --git a/config.go b/config.go index be91e59..2439e9c 100644 --- a/config.go +++ b/config.go @@ -4,6 +4,7 @@ type Configuration struct { Input string `arg:"" help:"code file to screenshot" optional:""` Language string `help:"code language" short:"l"` + Theme string `help:"theme" short:"t"` Output string `help:"output of the image" short:"o" default:"out.svg"` Window bool `help:"show window controls" short:"w" default:"false"` Border bool `help:"add an outline to the window" short:"b" default:"false"` diff --git a/examples/border.svg b/examples/border.svg index 5bcbd43..1c7beb3 100644 --- a/examples/border.svg +++ b/examples/border.svg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e79b152d6ca7e188a8e824e6bea08f045971dfc5f3df3f28c1327b6788c63f7e -size 126091 +oid sha256:d9fde70e23c64cbdf049f065288de2689ea29fb787eb64cc80591d812a185d43 +size 3007 diff --git a/go.mod b/go.mod index d0a8ce7..8c52868 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/freeze go 1.21 require ( - github.com/alecthomas/chroma v0.10.0 + github.com/alecthomas/chroma v0.10.1-0.20220126230913-d491f1b5c1d2 github.com/alecthomas/kong v0.8.1 github.com/beevik/etree v1.3.0 github.com/charmbracelet/log v0.3.1 diff --git a/go.sum b/go.sum index 9e33941..84d3fee 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2o github.com/alecthomas/assert/v2 v2.1.0/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= +github.com/alecthomas/chroma v0.10.1-0.20220126230913-d491f1b5c1d2 h1:Gg09t2u+C08At6TYucNrD3Cbaq97SUHax84BzQwRTgU= +github.com/alecthomas/chroma v0.10.1-0.20220126230913-d491f1b5c1d2/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/alecthomas/kong v0.8.1 h1:acZdn3m4lLRobeh3Zi2S2EpnXTd1mOL6U7xVml+vfkY= github.com/alecthomas/kong v0.8.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= diff --git a/main.go b/main.go index be58fa4..61e0ca0 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/formatters/svg" "github.com/alecthomas/chroma/lexers" + "github.com/alecthomas/chroma/styles" "github.com/alecthomas/kong" "github.com/beevik/etree" "github.com/charmbracelet/log" @@ -71,7 +72,15 @@ func main() { log.Fatal(err) } buf := &bytes.Buffer{} - err = f.Format(buf, style, it) + + fmt.Println(styles.Names()) + + s, ok := styles.Registry[strings.ToLower(config.Theme)] + if s == nil || !ok { + s = charmStyle + } + + err = f.Format(buf, s, it) if err != nil { log.Fatal(err) } diff --git a/style.go b/style.go index 53d2fa9..4563e1b 100644 --- a/style.go +++ b/style.go @@ -2,7 +2,7 @@ package main import "github.com/alecthomas/chroma" -var style = chroma.MustNewStyle("charm", chroma.StyleEntries{ +var charmStyle = chroma.MustNewStyle("charm", chroma.StyleEntries{ chroma.Text: "#C4C4C4", chroma.Error: "#F1F1F1 bg:#F05B5B", chroma.Comment: "#676767",