Skip to content

Executing "run" no longer works to forward to other commands #602

@Neunerlei

Description

@Neunerlei

Description

Hello there,

first of all thanks for creating this awesome tool, which I use basically in every project I work on.

I wrote quite a few cli tools running with bashly and really loved the possibility to create a command that forwards to another command if needed.

E.g. I have a environment control script with a npm install command, which first should execute the docker up command. Until now I did this by calling run docker up, followed by a run docker exec npm install in the npm install command.

Yes, I know I was using internals here, but I found it to be an amazing tool to reuse commands in an atomic pattern that did not involve rebooting the whole script over and over.

However, the latest change: 9167c49

breaks this behavior, because input and args are no longer reset, which currently breaks all scripts.
I'm currently considering my options here and wanted to ask if you could point me in a direction to fix this.
I'm currently thinking about creating a custom "forward_to" function in my library code which restores the old variable resetting, but that will be a lot of refactoring. 🤔

Alternatively I would like to kindly ask if you would consider rolling back the change to the previous behavior?

Thank you in any way!

edit: here is a bit of source code as context:

bashly.yaml

name: env
help: Environment Control application
version: 1.0.0
commands:
  - name: up
    help: similar to docker-compose up, but sets all the required environment
      variables for buildkit. (All docker command options are valid)
    catch_all: true
    flags:
      - long: --attach
        short: -f
        help: By default, the containers are started daemonized, use this to attach to
          their output
  - name: ssh
    alias: shell
    help: basically your docker-compose exec into the main app container
    args:
      - name: service
        help: Allows you to define which service you want to connect to
    flags:
      - long: --cmd
        short: -c
        arg: command
        default: bash
        help: By default, we will use "bash" as command, you can use "sh" or any other
          command if you want to
   - name: composer
    help: runs a certain composer command for the project
    catch_all: true         

up_command.sh

ARGS=${other_args[*]}

if ! [ ${args[--attach]} ]; then
	ARGS+=" -d"
fi

$DOCKER_COMPOSE_EXECUTABLE up $ARGS

ssh_command.sh

SERVICE=${args[service]:-$DEFAULT_SERVICE_NAME}
CMD=${args[--cmd]:-bash}

if ! isDockerComposeServiceRunning; then
  run up
fi
CONTAINER_ID=$(getContainerIdFromServiceName $SERVICE)

$DOCKER_EXECUTABLE \
  exec -ti \
  ${CONTAINER_ID} \
  bash -c "${CMD}"

composer_command.sh

CMD="${other_args[*]}"

run ssh -c "composer ${CMD}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeThis is not backwards compatiblebugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions