Skip to content

Commit 4acc450

Browse files
committed
Allow eg. pkg build node
Do a full naming-possibilityt look up for all commands
1 parent 957cbcf commit 4acc450

File tree

8 files changed

+36
-42
lines changed

8 files changed

+36
-42
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BrewKit is build infrastructure for `pkgx`.
66

77
```sh
88
$ env +brewkit
9-
$ pkg build zlib.net
9+
$ pkg build node
1010
```
1111

1212
If you are inside a pantry then BrewKit will figure out what packages you are
@@ -15,8 +15,10 @@ editing and build them.
1515
```sh
1616
$ cd pantry
1717
$ dev
18+
$ pkg edit openssl
19+
# make some edits…
1820
$ pkg build
19-
brewkit: building zlib.net
21+
brewkit: building openssl.org
2022
```
2123

2224
You can build for Linux (via Docker) using `-L`, e.g.:
@@ -32,7 +34,7 @@ Outside a pantry checkout we operate against your `pkgx` installation
3234
than local to your pantry checkout.
3335

3436
```sh
35-
pkgx +brewkit pkg build zlib.net
37+
env "$(pkgx +brewkit)" pkg build zlib.net
3638
```
3739

3840

bin/pkg-build

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#!/usr/bin/env -S pkgx bash
1+
#!/usr/bin/env -S pkgx bash -eo pipefail
22
# shellcheck shell=bash
33

4-
set -e
5-
64
PKGX_DIR=${PKGX_DIR:-"$HOME/.pkgx"}
75

86
if pwd | grep -q ' '; then
@@ -27,14 +25,14 @@ if test -z "$1"; then
2725
fi
2826
done
2927
else
30-
PKGS="$*"
28+
PKGS="$(find.ts $@)"
3129
fi
3230

3331
if test -n "$PKGX_DOCKER"; then
3432
exec "$d"/bin/pkg-docker build "$PKGS"
3533
fi
3634

37-
if ! available.ts "$@"; then
35+
if ! available.ts "$PKGS"; then
3836
echo "warning: not supported on current platform" >&2
3937
exit 0
4038
fi
@@ -53,7 +51,7 @@ PKGS="$(sort.ts $PKGS --delimiter ' ')"
5351
# ^^ ensures that pkgs build topologically
5452

5553
gum() {
56-
pkgx gum format -- "$@"
54+
pkgx gum format -- "$PKGS"
5755
}
5856

5957
for PKG in $PKGS; do

bin/pkg-clean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#!/usr/bin/env -S pkgx bash
1+
#!/usr/bin/env -S pkgx bash -eo pipefail
22
# shellcheck shell=bash
33

4-
set -e
5-
64
d="$(cd "$(dirname "$0")"/.. && pwd)"
75
PATH="$d/libexec:$PATH"
86

@@ -17,7 +15,7 @@ if test -z "$1"; then
1715
fi
1816
done
1917
else
20-
PKGS="$1"
18+
PKGS="$(find.ts $@)"
2119
fi
2220

2321
if test -z "$GITHUB_TOKEN"; then

bin/pkg-edit

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env -S pkgx bash
1+
#!/usr/bin/env -S pkgx bash -eo pipefail
22
# shellcheck shell=bash
33

44
set -e
@@ -17,9 +17,8 @@ if test -z "$1"; then
1717
PKGS="$(GIT_WORK_TREE="$x" peek.sh --print-paths)"
1818
fi
1919
done
20-
elif ! PKGS="$(find.ts $1)"; then
21-
echo "error: \`$1\` not found in \`\$PKGX_PANTRY_PATH\`" >&2
22-
exit 1
20+
else
21+
PKGS="$(_PATHS=1 find.ts $1)"
2322
fi
2423

2524
if test -z "$EDITOR"; then

bin/pkg-fetch

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#!/usr/bin/env -S pkgx bash
1+
#!/usr/bin/env -S pkgx bash -eo pipefail
22
# shellcheck shell=bash
33

4-
set -e
5-
64
d="$(cd "$(dirname "$0")"/.. && pwd)"
75
PATH="$d/libexec:$PATH"
86

@@ -30,7 +28,7 @@ if test -z "$1"; then
3028
fi
3129
done
3230
else
33-
PKGS="$1"
31+
PKGS="$(find.ts $1)"
3432
fi
3533

3634
if test -z "$GITHUB_TOKEN"; then

bin/pkg-fixup

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#!/usr/bin/env -S pkgx bash
1+
#!/usr/bin/env -S pkgx bash -eo pipefail
22
# shellcheck shell=bash
33

4-
set -e
5-
64
d="$(cd "$(dirname "$0")"/.. && pwd)"
75
PATH="$d/libexec:$PATH"
86

@@ -17,7 +15,7 @@ if test -z "$1"; then
1715
fi
1816
done
1917
else
20-
PKGS="$1"
18+
PKGS="$(find.ts $1)"
2119
fi
2220

2321
for PKG in $PKGS; do

bin/pkg-test

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#!/usr/bin/env -S pkgx bash
1+
#!/usr/bin/env -S pkgx bash -eo pipefail
22
# shellcheck shell=bash
33

4-
set -e
5-
64
d="$(cd "$(dirname "$0")"/.. && pwd)"
75
PATH="$d/libexec:$PATH"
86

@@ -17,7 +15,7 @@ if test -z "$1"; then
1715
fi
1816
done
1917
else
20-
PKGS="$*"
18+
PKGS="$(find.ts "$@")"
2119
fi
2220

2321
if test -n "$PKGX_DOCKER"; then

libexec/find.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
#!//usr/bin/env -S pkgx deno run --allow-read --allow-env
1+
#!/usr/bin/env -S pkgx deno run --allow-read --allow-env
22

33
import { hooks } from "pkgx"
4-
const { usePantry } = hooks
4+
const { find } = hooks.usePantry()
55

6-
const pantry = usePantry()
7-
const arg = Deno.args[0]
6+
for (const arg of Deno.args) {
7+
const rv = await find(arg)
88

9-
for await (const entry of pantry.ls()) {
10-
if (entry.project === arg) {
11-
console.info(entry.path.string)
12-
Deno.exit(0)
9+
if (rv.length > 1) {
10+
console.error("multiple matches: " + rv.map(({project}) => project).join(' '))
11+
Deno.exit(1)
1312
}
14-
if ((await pantry.project(entry).provides()).includes(arg)) {
15-
console.info(entry.path.string)
16-
Deno.exit(0)
13+
if (rv.length == 0) {
14+
console.error("no matches for: " + arg)
15+
Deno.exit(2)
1716
}
18-
}
1917

20-
Deno.exit(1)
18+
if (Deno.env.get("_PATHS")) {
19+
console.info(rv[0].path.string)
20+
} else {
21+
console.info(rv[0].project)
22+
}
23+
}

0 commit comments

Comments
 (0)