Skip to content

Commit b2dabac

Browse files
committed
docs: Fix docs to use 'bpm-load'
Eventually, 'package-path', will be removed for custom output string parsing for the 'list' subcommand
1 parent 6205207 commit b2dabac

File tree

3 files changed

+60
-8
lines changed

3 files changed

+60
-8
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,26 @@ Why not use `bpkg` or `Basher`? Because `hyperupcall/bpm`...
6060

6161
I forked Basher because it had an excellent test suite and its behavior for installing packages made more sense to me, compared to `bpkg`
6262

63+
Prior art
64+
6365
| Software | Deps | Versions | Locations | Completions |
6466
|---------------- |------|----------|--------------------| ----------- |
6567
| hyperupcall/bpm | Yes | Yes | Global, User, Repo | Yes |
6668
| [basher] | Yes | No | Global, User | Yes |
6769
| [bpkg] | Yes | Yes | Global, User, Repo | Yes |
6870
| [bpm-rocks/bpm] | Yes | No | Global, User, Repo | No |
6971
| [Themis] | Yes | Yes | Global, User, Repo | No |
70-
72+
| [xsh-lib/core] | ? | ? | | |
73+
| [shpkg] | | | | |
74+
| [jean] | | | | |
75+
| [sparrow] | | | | |
76+
| [tarp] | | | | |
7177
[basher]: https://github.com/basherpm/basher
7278
[bpkg]: https://github.com/bpkg/bpkg
7379
[bpm-rocks/bpm]: https://github.com/bpm-rocks/bpm/
7480
[Themis]: https://github.com/ByCh4n-Group/themis
81+
[xsh]: https://github.com/alexzhangs/xsh
82+
[shpkg]: https://github.com/shpkg/shpkg
83+
[jean]: https://github.com/ziyaddin/jean
84+
[sparrow]: https://github.com/melezhik/sparrow
85+
[tarp]: https://code.google.com/archive/p/tarp-package-manager/

docs/getting-started.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ But it doesn't work - this is standard behavior. When looking for binaries, bpm
7373
The authors of `z` did not mark the file as executable because they did not intend for you to execute the file - you are supposed to `source` it. This is why the `bpm-load` command exists:
7474

7575
```sh
76-
$ bpm --global package-path rupa/z
77-
/home/username/bpm/cellar/packages/rupa/z
76+
$ bpm-load --global --dry rupa/z z.sh
77+
bpm-load: Would source file '/home/edwin/data/bpm/cellar/packages/github.com/rupa/z/z.sh'
7878
```
7979

80-
Now, use the `package-path` to source `z.sh`. Note that `z.sh` only supports either Bash or Zsh, so you need to currently be in one of those shells for this to work
80+
Now, use the `bpm-load` to source `z.sh`. Note that `z.sh` only supports either Bash or Zsh, so you need to currently be in one of those shells for this to work. We `source 'bpm-source` because the PATH contains a file called `bpm-source`, which contains the `bpm-source` function that we use
8181

8282
```sh
83-
$ source "$(bpm --global package-path rupa/z)/z.sh"
83+
$ source 'bpm-source'
84+
$ bpm-source --global 'rupa/z' 'z.sh'
8485
$ z
8586
common: /tmp/tmp.MBF063fdlK/completions
8687
29988 /tmp/tmp.MBF063fdlK/completions
@@ -114,6 +115,6 @@ $ bpm --global remove \
114115
$ bpm --global list
115116
```
116117

117-
Note that we specified the SSH URL and the HTTPS URL when removing. You can specify the package this way with all commands, including the `add`, `package-path`, and `upgrade` commands
118+
Note that we specified the SSH URL and the HTTPS URL when removing. You can specify the package this way with all commands, including the `add`, `remove`, and `upgrade` commands
118119

119120
And you are done! To learn more, see [Recepies](./.recepies.md), [Reference](./reference.md), or [Tips](./tips.md)

pkg/lib/cmd/bpm-load.sh

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ bpm-load() {
2525
__bpm_flag_dry='yes'
2626
shift
2727
;;
28+
--help|-h)
29+
cat <<-"EOF"
30+
bpm-load
31+
32+
Usage:
33+
bpm-load <flags> <package> [file]
34+
35+
Flags:
36+
--global
37+
Use packages installed globally, rather than local packages
38+
39+
--dry
40+
Only print what would have been sourced
41+
42+
--help
43+
Print help menu
44+
45+
Example:
46+
bpm-load --global 'github.com/rupa/z' 'z.sh'
47+
EOF
48+
return
49+
;;
50+
-*)
51+
printf '%s\n' "bpm-load: Error: Flag '$arg' not recognized"
52+
return 1
53+
;;
2854
esac
2955
done
3056

@@ -79,12 +105,19 @@ bpm-load() {
79105
__bpm_cellar="${BPM_CELLAR:-"${XDG_DATA_HOME:-$HOME/.local/share}/bpm/cellar"}"
80106
else
81107
if ! __bpm_cellar="$(util.get_project_root_dir)/bpm_packages"; then
82-
printf '%s\n' "bpm-load: Error: Unexpected error calling function 'util.get_project_root_dir' with PWD '$PWD'"
108+
printf '%s\n' "bpm-load: Error: Unexpected error calling function 'util.get_project_root_dir' with \$PWD '$PWD'"
83109
__bpm_bpm_load_restore_options
84110
return 4
85111
fi
86112
fi
87113

114+
# Ensure package is actually installed
115+
if [ ! -d "$__bpm_cellar/packages/$__bpm_site/$__bpm_package" ]; then
116+
printf '%s\n' "bpm-load: Error: Package '$__bpm_site/$__bpm_package' is not installed. Does the '--global' flag apply?"
117+
__bpm_bpm_load_restore_options
118+
return 3
119+
fi
120+
88121
# Source file, behavior depending on whether it was specifed
89122
if [ -n "$__bpm_file" ]; then
90123
local __bpm_full_path="$__bpm_cellar/packages/$__bpm_site/$__bpm_package/$__bpm_file"
@@ -117,6 +150,7 @@ bpm-load() {
117150
for __bpm_file in 'load.bash'; do
118151
local __bpm_full_path="$__bpm_cellar/packages/$__bpm_site/$__bpm_package/$__bpm_file"
119152

153+
echo "$__bpm_full_path"
120154
if [ -f "$__bpm_full_path" ]; then
121155
__bpm_file_was_sourced='yes'
122156

@@ -136,7 +170,7 @@ bpm-load() {
136170
done
137171

138172
if [ "$__bpm_file_was_sourced" = 'no' ]; then
139-
printf '%s\n' "bpm-load: Error: Could not automatically find package file to source"
173+
printf '%s\n' "bpm-load: Error: Could not automatically find package file to source. Did you mean to pass the file to source as the second argument?"
140174
__bpm_bpm_load_restore_options
141175
return 3
142176
fi
@@ -160,3 +194,9 @@ __bpm_bpm_load_restore_options() {
160194
shopt -u extglob
161195
fi
162196
}
197+
198+
# @description Internal functions might call 'die', so this prevents 'bash: die: command not found' errors,
199+
# but still allows the error be exposed at the callsite
200+
die() {
201+
return 1
202+
}

0 commit comments

Comments
 (0)