Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

✨ Improved Command Line Interface #2667

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

SnaveSutit
Copy link
Contributor

@SnaveSutit SnaveSutit commented Feb 6, 2025

A rewrite of the Blockbench CLI, making it more powerful, and easier to understand.

Notable Changes so Far

  • Switched to using the commander library for argument parsing.
  • Added --no-auto-update option: Prevents Blockbench from auto-updating.
  • Added --install-custom-plugins <paths...> option: Attempts to load the listed file paths or URLs as plugins on startup.
  • Added --install-plugins <ids...> option: Attempts to install the listed IDs from the official plugins repository on startup.
  • Added --clean-installed-plugins option: Removes all installed plugins before startup.
  • Added --open-dev-tools option: Opens the dev tools on startup.
  • Added -v, --version option: Prints the installed version of Blockbench, then exits.
  • Added --hidden option: Hides the main window.
  • Added app.terminal console instance: Logs output to the terminal Blockbench was launched from with a fancy prefix:
    [00/00/0000 00:00:00] [Blockbench] ...
  • Added Blockbench.log function: Alias of app.terminal.
  • Added Plugin.log function: Alias of Blockbench.log, but includes the plugin ID in the prefix:
    [00/00/0000 00:00:00] [Blockbench] <plugin-id> ...
  • Added optional environment variables that mirror the CLI arguments. Eg. BLOCKBENCH_USER_DATA for --userData.
  • Added a -h, -help CLI option:
    image

- Switched CLI parsing to `commander` library.
- Added `--no-auto-update` CLI option.
- Added `--with-plugin-files <paths...>` CLI option.
- Added `--with-plugin-urls <urls...>` CLI option.
- Added optional environment variables that mirror the CLI arguments.
It should *just* output the version, and exit. It was throwing a `CommandError` and printing a bunch of extra text we don't want.
This file might be moved to `blockbench-types` later?
Whether or not that happens will be up to @JannisX11
- Added `app.terminal`: A Console instance that always prints to the terminal Blockbench was launched from (console.log switches to the web console after the window opens).
- Added `Blockbench.log`: An alias of `app.terminal`.
- Added `Plugin.log`: An alias of `Blockbench.log` that adds a `<plugin-id>` prefix to the output.
- Added a help option to all commands: `-h, --help`.
- Improved error handling, and user feedback when CLI encounters unexpected or unknown arguments.
- Added `--open-dev-tools` option: Opens the chrome developer tools on startup.
@SnaveSutit SnaveSutit changed the base branch from master to next February 8, 2025 23:48
@SnaveSutit SnaveSutit changed the base branch from next to master February 8, 2025 23:49
@SnaveSutit SnaveSutit marked this pull request as ready for review February 8, 2025 23:51
- Added `--clean-installed-plugins` option: Removes all installed plugins before launching.
- Fixed `app.console` references in `plugin_loader.js`.
- Replaced `--with-plugin-files` and `--with-plugin-urls` options with `--install-custom-plugins`.
- Added `--install-plugins <ids...>` option.
- Replaced all (new) `process.exit()` calls with `app.exit()`.
- Fixed `Blockbench.log` referencing `app.console` instead of `app.terminal`.
-
Copy link

@TheAfroOfDoom TheAfroOfDoom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ive had to migrate my map back from Smithed Summit work (haven't touched it since november, so ~4 months of afk), but i finally have time to check this out. i know i'm the main audience here so thank you </3

i tried using each CLI option and integrating it with my CI flow (the one that automates Animated Java's export process in Github Actions):

(i kept getting this error when opening dist/win-unpacked/Blockbench.exe through command prompt)
image

note: i had to update to AJ v1.6.4 (from v1.4.2) in order for my auto-exporter to run. it got some error that i don't think either of us care about given i can just easily update once i update my stuff to use these


  • clean-installed-plugins: according to the log appears to always run even when i don't specify the flag
  • no-auto-update: seems to work as intended 👍
  • install-custom-plugins: not immediately clear how to specify multiple plugins. comma-separated?

untested args:

  • open-dev-tools
  • install-plugins (probably useful and good to have as an alternative to install-custom-plugins, i just wont need it for my CI process/scripts since i want to tightly control plugin versions)
  • clean-installed-plugins (makes sense, don't think i have a real need for it currently though)
  • userData (would love some elaboration on this, i think i get what it's for but not sure)
  • hidden (i forgot, this one ill probably try using...maybe eventually)

js/cli.js Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when blockbench closes, it doesn't auto populate a new cmd line with the cwd. e.g., it's not obvious that the exe has exited from the command line
image

may be a side effect of the cmd maybe not being blocked while blockbench is open?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I genuinely have no clue what causes this. I'll dig into it further soon

@TheAfroOfDoom
Copy link

also question: is there a significant increase in load time when installing AJ via URL from "clean Blockbench" vs the normal startup AJ needs to do when it's already in Blockbench's plugin list?

@SnaveSutit
Copy link
Contributor Author

Animated Java is the largest plugin ever made for Blockbench. It takes a while to download, then download all of it's required external assets.

I haven't noticed any abnormally long delay when testing the CLI URL installation with AJ

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants