Skip to content

Commit

Permalink
feat: add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Sep 16, 2024
1 parent 674752d commit f35fac6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module examples

go 1.23.1

replace github.com/charmbracelet/colorprofile => ../

require (
github.com/charmbracelet/colorprofile v0.0.0-20240913192632-4a4ff4a5f48a // indirect
github.com/charmbracelet/x/ansi v0.3.1 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.24.0 // indirect
)
12 changes: 12 additions & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/charmbracelet/x/ansi v0.3.1 h1:CRO6lc/6HCx2/D6S/GZ87jDvRvk6GtPyFP+IljkNtqI=
github.com/charmbracelet/x/ansi v0.3.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
23 changes: 23 additions & 0 deletions examples/writer/writer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This package provides a writer that can be piped into to degrade the colors
// based on the terminal capabilities and profile.
package main

import (
"io"
"log"
"os"

"github.com/charmbracelet/colorprofile"
)

func main() {
w := colorprofile.NewWriter(os.Stdout, os.Environ())

// Read from stdin and write to stdout
bts, err := io.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}

_, err = w.Write(bts)
}

0 comments on commit f35fac6

Please sign in to comment.