Skip to content

Commit

Permalink
Update README and extra tools
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Apr 23, 2024
1 parent f559404 commit 6ecdf73
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 27 deletions.
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
# Haxe Manager

Easily download and switch haxe versions on UNIX (currently tested on
`ubuntu-latest` and `macos-latest` via github actions).
Easily download and switch haxe versions (currently tested on
`ubuntu-latest`, `macos-latest` and `windows-latest` via github actions).

Run `install.sh` and update `PATH` / `HAXE_STD_PATH` as requested.
Run `install.sh` (`install.bat` on Windows) and update `PATH` / `HAXE_STD_PATH` as
requested.

## Select a version

Run `hx` to display the haxe version switch (using [`fzf`](https://github.com/junegunn/fzf)).
Run `hx` to display the haxe version switch (using a Haxe port of [`fzf`](https://github.com/junegunn/fzf)
picker).

You can also skip the version picker by using directly `hx 4.3.0` (or any other
version/alias you have installed).
You can also skip the version picker by using directly `hx 4.3.0` or `hx select
4.3.0` (or any other version/alias you have installed).

## Installing / updating versions

Use `hx-download` tool to download haxe versions:
Use `hx download` tool to download haxe versions:

```
Usage: hx-download <VERSION> [AS_NAME]
Usage: hx download <VERSION> [AS_NAME]
Download official release VERSION (e.g., 4.3.0)
Save as AS_NAME if provided or use version number
or: hx-download latest [AS_NAME]
or: hx download latest [AS_NAME]
Download latest nightly
Save as AS_NAME if provided or use version number (with revision)
or: hx-download nightly <VERSION> [AS_NAME]
or: hx download nightly <VERSION> [AS_NAME]
or: hx download aws <VERSION> [AS_NAME]
Download specific nightly VERSION (e.g., 2023-01-22_development_dd5e467)
Save as AS_NAME if provided or use version number (with revision)
Note: short hash VERSION is also supported for development nightlies (e.g. dd5e467)
```

## List available versions

Use `hx list` to get a list of all haxe versions available throught your (local)
haxe-manager.

## Display currently selected version

Use `hx current` to display currently selected Haxe version string (equivalent
to running `haxe --version`).

On Unix, you can also run:
- `hx current --name` to get the name under which that version is installed
- `hx current --full` to get both name and version string (`[NAME] ([VERSION])`)

## Included tools

`extra/` folder contains optional tools you can install individually with their
`install.sh` script or all at once with `install-all.sh`.

Note that those have been written when Haxe Manager was unix only and probably
can't work at all on Windows.

### `hxfzf`

Prints a list of all `.hx` files in all your classpath, to be passed to `fzf`
Expand Down Expand Up @@ -73,10 +94,6 @@ the path to your repository if you're executing from somewhere else)

Update your local (git) copy of haxe-manager.

### `list-haxe-versions`

Get a list of all haxe versions available throught your (local) haxe-manager.

### `rofi-haxe`

[rofi](https://github.com/davatorium/rofi) wrapper to `hx` command, to graphically select a Haxe version.
Expand Down
2 changes: 1 addition & 1 deletion extra/fzf/hxfzf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ done
echo "$folders" \
| tr '\n' ' ' \
| xargs ag --hidden --silent -f -g ".hx" \
| grep -v "^/opt/haxe/std/\($targetFilter\)/"
| grep -v "^/opt/haxe/current/std/\($targetFilter\)/"
2 changes: 1 addition & 1 deletion extra/rofi/rofi-haxe.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

version=$(list-haxe-versions | rofi -dmenu -p "Set haxe version to" -no-custom -matching fuzzy -sorting-method fzf); hx-select $version
version=$(hx list | rofi -dmenu -p "Set haxe version to" -no-custom -matching fuzzy -sorting-method fzf); hx select $version
38 changes: 27 additions & 11 deletions src/HaxeManager.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class HaxeManager {
case ["current", []]: Sys.println(Utils.getCurrent().or(""));
case ["current", ["--name"]]:
if (Sys.systemName() == "Windows")
throw "`hx current --name` is not supported on windows";
throw "`hx current --name` is not supported on Windows";

Sys.println(Utils.getCurrentName().or(""));

case ["current", ["--full"]]:
if (Sys.systemName() == "Windows")
throw "`hx current --full` is not supported on windows";
throw "`hx current --full` is not supported on Windows";

Sys.println(Utils.getCurrentFull().or(""));

Expand All @@ -47,7 +47,7 @@ class HaxeManager {
var BOLD = ANSI.set(Bold);
var BOLD_OFF = ANSI.set(BoldOff);

Sys.println([
var lines = [
'${ORANGE}hx - Haxe Manager cli tool${RESET}',
'${UNDERLINE}https://github.com/kLabz/haxe-manager${UNDERLINE_OFF}',
'',
Expand All @@ -63,20 +63,36 @@ class HaxeManager {
' or: ${ORANGE}hx select ${UNDERLINE}<VERSION>${RESET}',
' Switch to installed Haxe version ${BOLD}VERSION${BOLD_OFF}',
'',
' or: ${ORANGE}hx current${RESET}',
' or: ${ORANGE}hx current --name${RESET}',
' or: ${ORANGE}hx current --full${RESET}',
' Display current Haxe version string',
' ${BOLD}--name${BOLD_OFF} will display the name under which this version has been installed',
' ${BOLD}--full${BOLD_OFF} will display both name and version string',
'',
];

if (Sys.systemName() == "Windows") {
lines = lines.concat([
' or: ${ORANGE}hx current${RESET}',
' Display current Haxe version string',
'',
]);
} else {
lines = lines.concat([
' or: ${ORANGE}hx current${RESET}',
' or: ${ORANGE}hx current --name${RESET}',
' or: ${ORANGE}hx current --full${RESET}',
' Display current Haxe version string',
' ${BOLD}--name${BOLD_OFF} will display the name under which this version has been installed',
' ${BOLD}--full${BOLD_OFF} will display both name and version string',
'',
]);
}

lines = lines.concat([
' or: ${ORANGE}hx list${RESET}',
' Display all installed Haxe versions',
'',
' or: ${ORANGE}hx --help${RESET}',
' or: ${ORANGE}hx --help download${RESET}',
' or: ${ORANGE}hx --help select${RESET}',
' Display help about available commands'
].join("\n"));
]);

Sys.println(lines.join("\n"));
}
}

0 comments on commit 6ecdf73

Please sign in to comment.