summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-06-14 17:50:45 +0200
committerewy <ewy0@protonmail.com>2026-06-14 17:50:45 +0200
commit40577525de2a01ca0b21a5d88757295ae7735580 (patch)
tree5b7bd7d3884e1524517f36913ca18ac3a5a4ae0e
parentfc9d57a500e522ce254f34681c67c6b2f3300cd8 (diff)
enable multiline for make regex so we can find multiple make targets (lol)
-rw-r--r--.pik/test.sh2
-rw-r--r--.pik/unittest.sh2
-rw-r--r--README.md6
-rw-r--r--go.mod2
-rw-r--r--go.sum18
-rw-r--r--integration_tests/make/Makefile8
-rw-r--r--integration_tests/make/simple.test.sh11
-rw-r--r--runner/gnumake/make.go4
-rw-r--r--spool/spool.go16
9 files changed, 41 insertions, 28 deletions
diff --git a/.pik/test.sh b/.pik/test.sh
index ac4945f..d5a99a6 100644
--- a/.pik/test.sh
+++ b/.pik/test.sh
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
-go test -tags test -v ./...
+bash .pik/unittest.sh
bash .pik/integrations.sh \ No newline at end of file
diff --git a/.pik/unittest.sh b/.pik/unittest.sh
new file mode 100644
index 0000000..8d105ed
--- /dev/null
+++ b/.pik/unittest.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+go test -tags test -v ./...
diff --git a/README.md b/README.md
index 33e62e1..ecf50c8 100644
--- a/README.md
+++ b/README.md
@@ -25,15 +25,15 @@ Grab a build from here:
### manual install
-* `git clone https://git.ewy.one/pik/`
+* `git clone https://git.sr.ht/~ewy/pik`
* `cd pik`
-if you were already using `pik`, `pik install` would suffice!
+if you were already a `pik` user, `pik install` would suffice.
thankfully you can `pik` yourself:
* `bash .pik/install.sh`
-wow! you just learned about `pik`s simplest usage!
+this is one of the most obvious ways to use `pik`.
## getting started
diff --git a/go.mod b/go.mod
index 3804444..6f69e4d 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,7 @@ go 1.26.1
require (
github.com/adrg/xdg v0.5.3
+ github.com/charmbracelet/bubbles v1.0.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/charmbracelet/x/term v0.2.2
@@ -16,7 +17,6 @@ require (
require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
- github.com/charmbracelet/bubbles v1.0.0 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/x/ansi v0.11.6 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
diff --git a/go.sum b/go.sum
index 5d8fc5d..acdf7f1 100644
--- a/go.sum
+++ b/go.sum
@@ -8,22 +8,14 @@ github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5f
github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
-github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
-github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
-github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
-github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
-github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
-github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
-github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
-github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA=
@@ -38,16 +30,12 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
-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/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
-github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
-github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
@@ -60,7 +48,6 @@ github.com/pelletier/go-toml/v2 v2.3.0 h1:k59bC/lIZREW0/iVaQR8nDHxVq8OVlIzYCOJf4
github.com/pelletier/go-toml/v2 v2.3.0/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
@@ -69,13 +56,10 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
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/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
-golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
+golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
-golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
diff --git a/integration_tests/make/Makefile b/integration_tests/make/Makefile
new file mode 100644
index 0000000..38ca1c2
--- /dev/null
+++ b/integration_tests/make/Makefile
@@ -0,0 +1,8 @@
+hello:
+ echo "Hello, World"
+
+other:
+ echo "Hello from Makefile!"
+
+dupe:
+ echo "maked"
diff --git a/integration_tests/make/simple.test.sh b/integration_tests/make/simple.test.sh
new file mode 100644
index 0000000..d6c9b7a
--- /dev/null
+++ b/integration_tests/make/simple.test.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+result="$($PIK hello)"
+if [[ ! "$result" == *"Hello, World"* ]] ; then
+ echo "expected Hello, World" >&2
+ exit 1
+fi
+result="$($PIK other)"
+if [[ ! "$result" == *"Hello from Makefile!"* ]] ; then
+ echo "expected Hello from Makefile!" >&2
+ exit 1
+fi
diff --git a/runner/gnumake/make.go b/runner/gnumake/make.go
index 93b523a..15b11ed 100644
--- a/runner/gnumake/make.go
+++ b/runner/gnumake/make.go
@@ -58,11 +58,11 @@ func (m *gnumake) Index(path string, f fs.FS, _ []model.Runner) ([]model.Target,
return ParseOutput(makefile), nil
}
-var makeRegex = regexp.MustCompile("^([a-zA-Z-]*):((.*?)# (.*))?")
+var makeRegex = regexp.MustCompile("(?m)^([a-zA-Z]*):((.*?)# (.*))?")
func ParseOutput(input string) []model.Target {
var targets []string
- match := makeRegex.FindAllString(input, len(input))
+ match := makeRegex.FindAllString(input, strings.Count(input, "\n"))
for _, m := range match {
targets = append(targets, m)
}
diff --git a/spool/spool.go b/spool/spool.go
index ce02dc5..9906906 100644
--- a/spool/spool.go
+++ b/spool/spool.go
@@ -2,6 +2,8 @@ package spool
import (
"fmt"
+ "git.sr.ht/~ewy/pik/menu/style"
+ "github.com/charmbracelet/lipgloss"
"os"
"reflect"
"runtime/debug"
@@ -9,8 +11,14 @@ import (
)
var (
- Stderr = os.Stderr
- Stdout = os.Stdout
+ Stderr = os.Stderr
+ Stdout = os.Stdout
+ StyleErr = style.New(func() lipgloss.Style {
+ return lipgloss.NewStyle().Foreground(lipgloss.Color("1"))
+ })
+ StyleWarn = style.New(func() lipgloss.Style {
+ return lipgloss.NewStyle().Foreground(lipgloss.Color("3"))
+ })
)
type empty struct{}
@@ -22,12 +30,12 @@ var Print = func(format string, values ...any) (any, error) {
}
var Warn = func(format string, values ...any) (any, error) {
- return fmt.Fprintf(Stderr, format, values...)
+ return fmt.Fprint(Stderr, StyleWarn.Render(fmt.Sprintf(format, values...)))
}
var Panic = func(code *ExitCode, format string, values ...any) (any, error) {
pkg := reflect.TypeOf(empty{}).PkgPath()
- v, err := fmt.Fprintf(Stderr, format, values...)
+ v, err := fmt.Fprint(Stderr, StyleErr.Render(fmt.Sprintf(format, values...)))
st := strings.Split(string(debug.Stack()), "\n")
for i, l := range st {
if strings.Contains(l, pkg) {