Technical/Core

:tasks

Package to import

Single task to import

PIP package to install

Stable version

rkd.core.standardlib

rkd.core.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.core.standardlib

rkd.core.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.core.standardlib

rkd.core.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.core.api.syntax import TaskDeclaration
from rkd.api.contract import ExecutionContext
from rkd.core.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.core.standardlib. CallableTask ( name : str , callback : Callable [ [ rkd.core.api.contract.ExecutionContext , rkd.core.api.contract.TaskInterface ] , bool ] , args_callback : Optional [ Callable [ [ argparse.ArgumentParser ] , None ] ] = None , description : str = '' , group : str = '' , become : str = '' , argparse_options : Optional [ List [ rkd.core.api.contract.ArgparseArgument ] ] = None ) [source]

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

configure_argparse ( parser : argparse.ArgumentParser ) [source]

Allows a task to configure ArgumentParser (argparse)

def configure_argparse(self, parser: ArgumentParser):
    parser.add_argument('--php', help='PHP version ("php" docker image tag)', default='8.0-alpine')
    parser.add_argument('--image', help='Docker image name', default='php')
execute ( context : rkd.core.api.contract.ExecutionContext ) bool [source]

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

get_become_as ( ) str [source]

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 ] [source]

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

All environment variables fetched from the ExecutionContext needs to be defined there. Declared values there are automatically documented in –help

@classmethod
def get_declared_envs(cls) -> Dict[str, Union[str, ArgumentEnv]]:
    return {
        'PHP': ArgumentEnv('PHP', '--php', '8.0-alpine'),
        'IMAGE': ArgumentEnv('IMAGE', '--image', 'php')
    }
get_group_name ( ) str [source]

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

get_name ( ) str [source]

Task name eg. “:sh”

:rkd:create-structure

Hint

This is an extendable task. Read more in Extending tasks chapter.

Package to import

Single task to import

PIP package to install

Stable version

rkd.core.standardlib

rkd.core.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.core.standardlib. CreateStructureTask [source]

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 ) [source]

Allows a task to configure ArgumentParser (argparse)

def configure_argparse(self, parser: ArgumentParser):
    parser.add_argument('--php', help='PHP version ("php" docker image tag)', default='8.0-alpine')
    parser.add_argument('--image', help='Docker image name', default='php')
execute ( ctx : rkd.core.api.contract.ExecutionContext ) bool [source]

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

get_group_name ( ) str [source]

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

get_name ( ) str [source]

Task name eg. “:sh”

get_patterns_to_add_to_gitignore ( ctx : rkd.core.api.contract.ExecutionContext ) list [source]

List of patterns to write to .gitignore

Interface method: to be overridden

on_creating_venv ( ctx : rkd.core.api.contract.ExecutionContext ) None [source]

When creating virtual environment

Interface method: to be overridden

on_files_copy ( ctx : rkd.core.api.contract.ExecutionContext ) None [source]

When files are copied

Interface method: to be overridden

on_git_add ( ctx : rkd.core.api.contract.ExecutionContext ) None [source]

Action on, when adding files via git add

Interface method: to be overridden

on_requirements_txt_write ( ctx : rkd.core.api.contract.ExecutionContext ) None [source]

After requirements.txt file is written

Interface method: to be overridden

on_startup ( ctx : rkd.core.api.contract.ExecutionContext ) None [source]

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

Interface method: to be overridden

print_success_msg ( use_pipenv : bool , ctx : rkd.core.api.contract.ExecutionContext ) None [source]

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.core.standardlib

rkd.core.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