Skip to content

Commit 248d9f5

Browse files
committed
fix misleading zls version in README and install script
1 parent 51fc7b7 commit 248d9f5

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
bin/install
3030
- run: |
3131
${ASDF_INSTALL_PATH}/bin/zig env
32+
${ASDF_INSTALL_PATH}/bin/zls version
3233
3334
plugin-test:
3435
strategy:

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
As a bonus, this plugin supports installing zls as well, so zls and zig version can match exactly.
88

9-
109
</div>
1110

1211
# Dependencies
@@ -22,13 +21,23 @@ After installing [asdf](https://asdf-vm.com/guide/getting-started.html), install
2221
asdf plugin add zig https://github.com/asdf-community/asdf-zig.git
2322
```
2423

25-
Then use `asdf-zig` to install zig:
24+
or update an existing installation:
25+
26+
```shell
27+
asdf plugin update zig
28+
```
29+
30+
Then use `asdf-zig` to manage zig:
2631

2732
```shell
2833
# Show all installable versions
2934
asdf list all zig
3035

3136
# Install specific version
37+
38+
asdf install zig 0.15.1
39+
40+
# or install latest tagged version with
3241
asdf install zig latest
3342

3443
# Set a version globally (on your ~/.tool-versions file)
@@ -37,7 +46,8 @@ asdf set --home zig latest
3746
# Now zig commands are available
3847
zig version
3948

40-
# Also you can check zls match zig version
49+
# You can also check the ZLS version.
50+
# It is designed to be highly compatible with the specific Zig version you installed.
4151
zls version
4252
```
4353

@@ -46,4 +56,4 @@ install & manage versions.
4656

4757
# License
4858

49-
See [LICENSE](LICENSE)
59+
[Apache License 2.0](LICENSE)

bin/install

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ install_version() {
2626
exit 1
2727
fi
2828

29-
echo "zig $version installation was successful!"
29+
echo "Zig $version installation was successful!"
3030
if test -x "$install_path/bin/zls"; then
31-
echo "zls $version also get installed!"
31+
zls_version=$($install_path/bin/zls version)
32+
echo "ZLS $zls_version, which is highly compatible with Zig $version, was also installed successfully!"
3233
fi
3334
) || (
3435
rm -rf "$install_path"

lib/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ def fetch_index():
6161
return json.loads(body)
6262

6363

64+
def format_size(size_in_bytes):
65+
"""Convert a size in bytes to a human-readable format (K, M, G, etc.)."""
66+
for unit in ['B', 'K', 'M', 'G', 'T', 'P']:
67+
if size_in_bytes < 1024:
68+
return f'{size_in_bytes:.2f}{unit}'
69+
size_in_bytes /= 1024
70+
return f'{size_in_bytes:.2f}P' # Handle extremely large sizes
71+
72+
6473
def query_zls(zig_version):
6574
url = f'https://releases.zigtools.org/v1/zls/select-version?zig_version={zig_version}&compatibility=full'
6675
with http_get(url) as response:
@@ -77,7 +86,7 @@ def all_versions():
7786

7887
def download_and_check(url, out_file, expected_shasum, total_size):
7988
logging.info(f'Begin download tarball({total_size}) from {url} to {out_file}...')
80-
chunk_size = 1024 * 1024 # 1M chunks
89+
chunk_size = 1024 * 1024 * 2 # 2M chunks
8190
sha256_hash = hashlib.sha256()
8291
with http_get(url) as response:
8392
read_size = 0
@@ -89,7 +98,7 @@ def download_and_check(url, out_file, expected_shasum, total_size):
8998
(read_size / total_size) * 100 if total_size > 0 else 0
9099
)
91100
logging.info(
92-
f'Downloaded: {read_size}/{total_size} bytes ({progress_percentage:.2f}%)'
101+
f'Downloaded: {format_size(read_size)}/{format_size(total_size)} bytes ({progress_percentage:.2f}%)'
93102
)
94103
if not chunk:
95104
break # eof

0 commit comments

Comments
 (0)