Skip to content

Commit

Permalink
Make interactive cli optional, disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisCris committed Apr 22, 2024
1 parent c019075 commit a7b3f15
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 49 deletions.
3 changes: 1 addition & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ if [ -n "$APP_PORT" ]; then cmd="$cmd --port=$APP_PORT"; fi
if [ -n "$MODE" ]; then cmd="$cmd --mode=\"$MODE\""; fi
if [ -n "$SAVE_PATH" ]; then cmd="$cmd --path=\"$SAVE_PATH\""; fi
if [ -n "$PASSWORD" ]; then cmd="$cmd --password=\"$PASSWORD\""; fi
# if [ -n "$PY_INTERACTIVE_FLAG" ]; then cmd="$cmd $PY_INTERACTIVE_FLAG"; fi
if [ -n "$INTERACTIVE" ]; then cmd="$cmd --interactive=\"$INTERACTIVE\""; fi

echo "Launching: $cmd"

# Execute the command
eval exec $cmd
6 changes: 0 additions & 6 deletions setup_and_run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,9 @@ if ($majorVersion -lt 3 -or ($majorVersion -eq 3 -and $minorVersion -lt 11)) {

Write-Host "Using $($PYTHON_CMD) (version $($majorVersion).$($minorVersion))"

# Create and activate virtual environment
& $PYTHON_CMD -m venv venv
. .\venv\Scripts\Activate.ps1

# Install dependencies
pip install -r requirements.txt

# Install your package in editable mode
pip install -e .

# Run your package in interactive mode
python -m palworld_pal_editor $args
36 changes: 0 additions & 36 deletions setup_and_run.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
#!/bin/bash

# # modified for the use of docker image
# # Default values
# PY_INTERACTIVE_MODE=""
# LANG=""
# PORT=""
# MODE=""
# SAVE_PATH=""
# PASSWORD=""

# # Process command-line arguments
# while [[ "$#" -gt 0 ]]; do
# case $1 in
# --i) PY_INTERACTIVE_MODE="-i"; shift ;;
# --lang) LANG="--lang \"$2\""; shift ;;
# --port) PORT="--port \"$2\""; shift ;;
# --mode) MODE="--mode \"$2\""; shift ;;
# --path) SAVE_PATH="--path \"$2\""; shift ;;
# --password) PASSWORD="--password \"$2\""; shift ;;
# *) echo "Unknown parameter passed: $1"; exit 1 ;;
# esac
# shift
# done

if which npm > /dev/null; then
NPM_CMD=npm
else
Expand Down Expand Up @@ -59,24 +34,13 @@ fi

echo "Using ${PYTHON_CMD} (version ${PYTHON_VERSION})"

# Create a virtual environment named 'venv' (skip if already created)
${PYTHON_CMD} -m venv venv

# Activate the virtual environment
source venv/bin/activate

# Install packages from requirements.txt
pip install -r requirements.txt

# Install your package in editable mode
pip install -e .

# COMMAND_ARGS="$MODE $LANG $PORT $SAVE_PATH $PASSWORD"

# Log the arguments before invoking Python
# echo "Running command: python $PY_INTERACTIVE_MODE -m palworld_pal_editor $COMMAND_ARGS"

# Use eval to correctly handle spaces in paths and other arguments
launch_command="python -m palworld_pal_editor ${@}"
echo "Launching $launch_command..."
eval $launch_command
11 changes: 6 additions & 5 deletions src/palworld_pal_editor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ def setup_config_from_args():
parser = argparse.ArgumentParser(description="Palworld Pal Editor, developed by _connlost with ❤.")

parser.add_argument('--lang', type=str, help=f'Language for the application. options: {", ".join(DataProvider.get_i18n_options())}', default=Config.i18n)
parser.add_argument('--debug', action='store_true', help='Debug option, only mimics interactive mode for VSCode debug launch.', default=Config.debug)
parser.add_argument('--debug', action='store_true', help='The debug option, only for VSCode debug launch.')
parser.add_argument('--path', type=str, help='Path to the save folder.', default=Config.path)
parser.add_argument('--mode', type=str, help='Running Mode, options: cli, gui, web', default=Config.mode)
parser.add_argument('--port', type=int, help='Port used for WebUI mode.', default=Config.port)
parser.add_argument('--password', type=str, help='Password for WebUI.', default=Config.password)
parser.add_argument('--interactive', action='store_true', help='Enable Interactive CLI.')

args = parser.parse_args()
try:
Config.set_configs({
"debug": args.debug,
"debug": Config.debug or args.debug, # True value in config overrides the cli arg.
"interactive": Config.interactive or args.interactive,
"path": args.path,
"mode": args.mode,
"port": args.port,
Expand Down Expand Up @@ -58,13 +60,12 @@ def main():
LOGGER.info(Config.__str__())
LOGGER.info(f"Running Palworld-Pal-Editor version: {VERSION}")
match Config.mode:
# case "cli": globals().update(cli_main())
case "cli": cli_main()
case "gui":
InteractThread.load()
if Config.interactive: InteractThread.load()
gui_main()
case "web":
InteractThread.load()
if Config.interactive: InteractThread.load()
webui_main()

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions src/palworld_pal_editor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Config:
debug: bool = False
path: str = None
password: str = None
interactive: bool = False
_password_hash: str = None
JWT_SECRET_KEY: str = "X2Nvbm5sb3N0"

Expand Down

0 comments on commit a7b3f15

Please sign in to comment.