How can I define Run actions that let me pass thro...
# 🤖|ask-kapa
f
@microscopic-river-74022 How can I define Run actions that let me pass through additional flags to commands? I simply mean that I want to be able to say run migrate-generate -- -m "Create applications table" and for the -m "create applications table" portion to be passed to the underlying command. Something like:
Copy code
kind: Run
type: container
name: migrate-generate
build: api
description: Perform alembic migration
dependencies:
  - deploy.cockroach-db
  - run.cockroach-seed-users
spec:
  command:
  - hatch
  - run 
  - python 
  - -m 
  - alembic 
  - revision 
  - --autogenerate
  - ${command.$rest}
  env:
    PYTHONPATH: ./src
    NATS_URL: "nats://nats-server:4222"
    SQLALCHEMY_DATABASE_URL: "roach:roach@cockroachdb:26257/kraken"
m
Please stand by @fresh-yak-35965 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- In Garden, you can define Run actions that allow you to pass additional flags to commands. You can use the
$concat
function to pass any additional parameters through to the command without validation. Here's how you can modify your
garden.yml
file:
Copy code
yaml
kind: Run
type: container
name: migrate-generate
build: api
description: Perform alembic migration
dependencies:
  - deploy.cockroach-db
  - run.cockroach-seed-users
spec:
  command:
  - hatch
  - run 
  - python 
  - -m 
  - alembic 
  - revision 
  - --autogenerate
  - $concat: ${args.$rest}  # <- pass any additional parameters through to the command without validation
  env:
    PYTHONPATH: ./src
    NATS_URL: "nats://nats-server:4222"
    SQLALCHEMY_DATABASE_URL: "roach:roach@cockroachdb:26257/kraken"
Now you can run your command with additional flags like this:
garden run migrate-generate -- -m "Create applications table"
. The
-m "Create applications table"
portion will be passed to the underlying command. Please note that this feature is part of Garden's advanced custom commands functionality. You can read more about it in the official Garden documentation (). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted