Shell¶
Provides tasks for shell commands execution - mostly used in YAML syntax and in Python modules.
:sh¶
Package to import | Single task to import | PIP package to install | Stable version |
---|---|---|---|
rkd.standardlib.shell | rkd.standardlib.shell.ShellCommandTask | pip install rkd== SELECT VERSION |
Executes a Bash script. Can be multi-line.
Notice: phrase %RKD% is replaced with an rkd binary name
Example of plain usage:
rkd :sh -c "ps aux"
rkd :sh --background -c "some-heavy-task"
Example of task alias usage:
from rkd.api.syntax import TaskAliasDeclaration as Task
#
# Example of Makefile-like syntax
#
IMPORTS = []
TASKS = [
Task(':find-images', [
':sh', '-c', 'find ../../ -name \'*.png\''
]),
Task(':build', [':sh', '-c', ''' set -x;
cd ../../../
chmod +x setup.py
./setup.py build
ls -la
'''])
]
:exec¶
Package to import | Single task to import | PIP package to install | Stable version |
---|---|---|---|
rkd.standardlib.shell | rkd.standardlib.shell.ExecProcessCommand | pip install rkd== SELECT VERSION |
Works identically as :sh, but for spawns a single process. Does not allow a multi-line script syntax.
Class to import: BaseShellCommandWithArgumentParsingTask¶
Creates a command that executes bash script and provides argument parsing using Python’s argparse. Parsed arguments are registered as ARG_{{argument_name}} eg. –activity-type would be exported as ARG_ACTIVITY_TYPE.
IMPORTS += [
BaseShellCommandWithArgumentParsingTask(
name=":protest",
group=":activism",
description="Take action!",
arguments_definition=lambda argparse: (
argparse.add_argument('--activity-type', '-t', help='Select an activity type')
),
command='''
echo "Let's act! Let's ${ARG_ACTIVITY_TYPE}!"
'''
)
]