Skip to content

Commit 2a00f42

Browse files
committed
test: Fix all tests
1 parent dab4353 commit 2a00f42

16 files changed

+126
-71
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To be able to access the binaries, completion files, and man pages in your shell
3030
```sh
3131
# ~/.bashrc
3232
export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/basalt/source/pkg/bin:$PATH"
33-
eval "$(basalt init bash)" # zsh and fish are also supported
33+
eval "$(basalt global init bash)" # zsh and fish are also supported
3434
```
3535

3636
See [Installation](./docs/tutorials/installation.md) and [Getting Started](./docs/tutorials/getting-started.md) for more details

docs/tutorials/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For `bash`, `zsh`, `sh`
4545

4646
```sh
4747
export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/basalt/source/pkg/bin:$PATH"
48-
eval "$(basalt init bash)" # replace 'bash' with your shell
48+
eval "$(basalt global init bash)" # replace 'bash' with your shell
4949
```
5050

5151
For `fish`

pkg/lib/commands/do-global-init.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ echo_package_path_posix() {
3030
# - Setting basalt package PATH
3131
# - Sourcing basalt package completion
3232
do-global-init() {
33-
if [ "$1" = '-' ]; then
34-
shift
35-
fi
36-
3733
local shell="$1"
3834

3935
if [ -z "$shell" ]; then

pkg/lib/commands/do-init.sh

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,96 @@
11
# shellcheck shell=bash
22

33
do-init() {
4-
if [ -e basalt.toml ]; then
5-
bprint.die "File 'basalt.toml' already exists"
4+
local flag_type=
5+
local -a args=()
6+
for arg; do case "$arg" in
7+
--bare)
8+
flag_type='bare'
9+
;;
10+
--full)
11+
flag_type='full'
12+
;;
13+
-*)
14+
bprint.die "Flag '$arg' not recognized"
15+
;;
16+
*)
17+
args+=("$arg")
18+
;;
19+
esac done
20+
21+
if ((${#args[@]} > 0)); then
22+
bprint.die "No arguments must be specified"
623
fi
724

8-
cat >| basalt.toml <<-"EOF"
9-
[package]
10-
name = ''
11-
slug = ''
12-
version = ''
13-
authors = []
14-
description = ''
25+
case "$flag_type" in
26+
'')
27+
bprint.die "Must either specify '--bare' or '--full'. No default choice has been implemented"
28+
;;
29+
bare)
30+
if [ -f 'basalt.toml' ]; then
31+
bprint.die "File 'basalt.toml' already exists"
32+
fi
33+
34+
local file1="./basalt.toml"
35+
if ! cat >| "$file1" <<-"EOF"; then
36+
[package]
37+
name = ''
38+
slug = ''
39+
version = ''
40+
authors = []
41+
description = ''
42+
43+
[run]
44+
dependencies = []
45+
sourceDirs = []
46+
builtinDirs = []
47+
binDirs = []
48+
completionDirs = []
49+
manDirs = []
50+
51+
[run.shellEnvironment]
52+
53+
[run.setOptions]
1554
16-
[run]
17-
dependencies = []
18-
sourceDirs = []
19-
builtinDirs = []
20-
binDirs = []
21-
completionDirs = []
22-
manDirs = []
55+
[run.shoptOptions]
56+
EOF
57+
bprint.die "Could not write to $file1"
58+
fi
59+
bprint.info "Created $file1"
2360

24-
[run.shellEnvironment]
2561

26-
[run.setOptions]
62+
mkdir -p 'pkg/bin'
63+
local file2="./pkg/bin/file"
64+
if ! cat >| "$file2" <<-"EOF"; then
65+
#!/usr/bin/env bash
2766
28-
[run.shoptOptions]
29-
EOF
67+
eval "$(basalt-package-init)"; basalt.package-init
68+
basalt.package-load
69+
70+
source "$BASALT_PACKAGE_PATH/pkg/lib/cmd/file.sh"
71+
file.main "$@"
72+
EOF
73+
bprint.die "Could not write to $file2"
74+
fi
75+
bprint.info "Created $file2"
76+
77+
78+
mkdir -p 'pkg/lib/cmd'
79+
local file3="./pkg/lib/cmd/file.sh"
80+
if ! cat >| "$file3" <<"EOF"; then
81+
file.main() {
82+
printf '%s\n' "Woof!"
83+
}
84+
EOF
85+
bprint.die "Could not write to $file3"
86+
fi
87+
bprint.info "Created $file3"
3088

31-
bprint.info "Created basalt.toml"
89+
;;
90+
full)
91+
if ! git clone -q 'https://github.com/hyperupcall/template-bash' .; then
92+
bprint.die "Could not clone the full bash template"
93+
fi
94+
;;
95+
esac
3296
}

pkg/lib/commands/do-list.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
do-list() {
44
util.init_local
55

6+
if (($# != 0)); then
7+
bprint.warn "No arguments or flags must be specified"
8+
fi
9+
610
if util.get_toml_array "$BASALT_LOCAL_PROJECT_DIR/basalt.toml" 'dependencies'; then
711
for dependency in "${REPLIES[@]}"; do
812
util.get_package_info "$dependency"

pkg/lib/commands/do-run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ do-run() {
1313
;;
1414
esac done
1515

16+
if ((${#args[@]} == 0)); then
17+
bprint.die "The name of an executable must be passed"
18+
fi
19+
1620
if ((${#args[@]} > 1)); then
1721
bprint.die "The only argument must be the executable name"
1822
fi

pkg/lib/util/ensure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ensure.nonzero() {
3232

3333
local -n value="$name"
3434
if [ -z "$value" ]; then
35-
bprint.fatal "Argument '$name' for function '${FUNCNAME[1]} ${FUNCNAME[2]} ${FUNCNAME[3]}' is empty"
35+
bprint.fatal "Argument '$name' for function '${FUNCNAME[1]}' is empty"
3636
fi
3737
}
3838

pkg/lib/util/print.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ bprint.fatal() {
1515
else
1616
printf "\033[0;31m%11s\033[0m %s\n" 'Fatal' "$1"
1717
fi
18+
19+
exit 1
1820
}
1921

2022
bprint.error() {

pkg/lib/util/util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ util.get_package_info() {
276276
site="github.com"
277277
package="$input"
278278
else
279-
bprint.die "String '$pkg' does not look like a package"
279+
bprint.die "String '$input' does not look like a package"
280280
fi
281281

282282
if [[ "$package" == *@* ]]; then

0 commit comments

Comments
 (0)