Python Commands
This example demonstrates how to configure garden.shell
to use python3
when running custom commands.
Examples
garden hello
garden info
# Pass additional arguments after the double-dash `--` end-of-options marker.
garden hello -- cat
garden.yaml
# Demo using "python3" as the interpreter for custom commands.
garden:
shell: python3
commands:
hello: |
import sys
# dash_c = sys.argv[0] # sys.argv[0] contains '-c'
args = sys.argv[1:] # additional arguments specified after '--'
if args:
world = ' '.join(args)
else:
world = 'world'
print(f'hello {world}')
info: |
import os
import sys
print(f'os.name = {os.name}')
print(f'sys.platform = {sys.platform}')
print(r'sys.int_info = {sys.int_info}')
print('uname = ${uname}')
variables:
# NOTE: exec expressions are always run using the system's default #!/bin/sh shell.
uname: $ uname -a