Technical/Core

:init

Package to import Single task to import PIP package to install Stable version
rkd.standardlib rkd.standardlib.InitTask pip install rkd== SELECT VERSION https://badgen.net/pypi/v/rkd

This task runs ALWAYS. :init implements a possibility to inherit global settings to other tasks

:tasks

Package to import Single task to import PIP package to install Stable version
rkd.standardlib rkd.standardlib.TasksListingTask pip install rkd== SELECT VERSION https://badgen.net/pypi/v/rkd

Lists all tasks that are loaded by all chained makefile.py configurations.

Environment variables:

  • RKD_WHITELIST_GROUPS: (Optional) Comma separated list of groups to only show on the list
  • RKD_ALIAS_GROUPS: (Optional) Comma separated list of groups aliases eg. “:international-workers-association->:iwa,:anarchist-federation->:fa”

:version

Package to import Single task to import PIP package to install Stable version
rkd.standardlib rkd.standardlib.VersionTask pip install rkd== SELECT VERSION https://badgen.net/pypi/v/rkd

Shows version of RKD and lists versions of all loaded tasks, even those that are provided not by RiotKit. The version strings are taken from Python modules as RKD strongly rely on Python Packaging.

CallableTask

Package to import Single task to import PIP package to install Stable version
rkd.standardlib rkd.standardlib.CallableTask pip install rkd== SELECT VERSION https://badgen.net/pypi/v/rkd

This is actually not a task to use directly, it is a template of a task to implement yourself. It’s kind of a shortcut to create a task by defining a simple method as a callback.


import os
from rkd.api.syntax import TaskDeclaration
from rkd.api.contract import ExecutionContext
from rkd.standardlib import CallableTask


def union_method(context: ExecutionContext) -> bool:
    os.system('xdg-open https://iwa-ait.org')
    return True


IMPORTS = [
    TaskDeclaration(CallableTask(':create-union', union_method))
]

TASKS = []
class rkd.standardlib.CallableTask(name: str, callback: Callable[[rkd.api.contract.ExecutionContext, rkd.api.contract.TaskInterface], bool], args_callback: Callable[[argparse.ArgumentParser], None] = None, description: str = '', group: str = '', become: str = '', argparse_options: List[rkd.api.contract.ArgparseArgument] = None)

Executes a custom callback - allows to quickly define a short task

configure_argparse(parser: argparse.ArgumentParser)

Allows a task to configure ArgumentParser (argparse)

execute(context: rkd.api.contract.ExecutionContext) → bool

Executes a task. True/False should be returned as return

get_become_as() → str

User name in UNIX/Linux system, optional. When defined, then current task will be executed as this user (WARNING: a forked process would be started)

get_declared_envs() → Dict[str, str]

Dictionary of allowed envs to override: KEY -> DEFAULT VALUE

get_group_name() → str

Group name where the task belongs eg. “:publishing”, can be empty.

get_name() → str

Task name eg. “:sh”

:rkd:create-structure

Package to import Single task to import PIP package to install Stable version
rkd.standardlib rkd.standardlib.CreateStructureTask pip install rkd== SELECT VERSION https://badgen.net/pypi/v/rkd

Creates a template structure used by RKD in current directory.

API for developers:

This task is extensible by class inheritance, you can override methods to implement your own task with changed behavior. It was designed to allow to create customized installers for tools based on RKD (custom RKD distributions), the example is RiotKit Harbor.

Look for “interface methods” in class code, those methods are guaranteed to not change from minor version to minor version.

class rkd.standardlib.CreateStructureTask

Creates a RKD file structure in current directory

This task is designed to be extended, see methods marked as “interface methods”.

configure_argparse(parser: argparse.ArgumentParser)

Allows a task to configure ArgumentParser (argparse)

execute(ctx: rkd.api.contract.ExecutionContext) → bool

Executes a task. True/False should be returned as return

get_group_name() → str

Group name where the task belongs eg. “:publishing”, can be empty.

get_name() → str

Task name eg. “:sh”

get_patterns_to_add_to_gitignore(ctx: rkd.api.contract.ExecutionContext) → list

List of patterns to write to .gitignore

Interface method: to be overridden

on_creating_venv(ctx: rkd.api.contract.ExecutionContext) → None

When creating virtual environment

Interface method: to be overridden

on_files_copy(ctx: rkd.api.contract.ExecutionContext) → None

When files are copied

Interface method: to be overridden

on_git_add(ctx: rkd.api.contract.ExecutionContext) → None

Action on, when adding files via git add

Interface method: to be overridden

on_requirements_txt_write(ctx: rkd.api.contract.ExecutionContext) → None

After requirements.txt file is written

Interface method: to be overridden

on_startup(ctx: rkd.api.contract.ExecutionContext) → None

When the command is triggered, and the git is not dirty

Interface method: to be overridden

print_success_msg(use_pipenv: bool, ctx: rkd.api.contract.ExecutionContext) → None

Emits a success message

Interface method: to be overridden

:file:line-in-file

Package to import Single task to import PIP package to install Stable version
rkd.standardlib rkd.standardlib.LineInFileTask pip install rkd== SELECT VERSION https://badgen.net/pypi/v/rkd

Similar to the Ansible’s lineinfile, replaces/creates/deletes a line in file.

Example usage:

echo "Number: 10" > test.txt

rkd -rl debug :file:line-in-file test.txt --regexp="Number: ([0-9]+)?(.*)" --insert='Number: $match[0] / new: 10'
cat test.txt

rkd -rl debug :file:line-in-file test.txt --regexp="Number: ([0-9]+)?(.*)" --insert='Number: $match[0] / new: 6'
cat test.txt

rkd -rl debug :file:line-in-file test.txt --regexp="Number: ([0-9]+)?(.*)" --insert='Number: 50'
cat test.txt

rkd -rl debug :file:line-in-file test.txt --regexp="Number: ([0-9]+)?(.*)" --insert='Number: $match[0] / new: 90'
cat test.txt