Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
#66: Improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Jul 14, 2021
1 parent 8ef20b1 commit 86bbf3a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/php/tests/samples/.rkd/makefile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from rkd.core.execution.lifecycle import ConfigurationLifecycleEvent
from rkd.core.api.contract import ExecutionContext
from rkd.core.execution.lifecycle import ConfigurationLifecycleEvent, CompilationLifecycleEvent
from rkd.core.standardlib import ShellCommandTask
from rkd.php import ComposerIntegrationTask, PhpScriptTask
from rkd.core.api.syntax import TaskDeclaration, ExtendedTaskDeclaration
from rkd.core.api.decorators import no_parent_call, extends, call_parent_first
Expand Down Expand Up @@ -52,10 +54,32 @@ def configure(task: PhpScriptTask, event: ConfigurationLifecycleEvent):
# return [configure]


# =================
# compile() example
# =================
# Compilation takes place very early - even before task is picked into current execution context
# so it is a good place to configure task settings that affects eg. arguments parsing (as it is done on early stage)
#
@extends(ShellCommandTask)
def ListWorkspaceFiles():
def compile(task: ShellCommandTask, event: CompilationLifecycleEvent):
task.is_cmd_required = False

def stdin():
return '''ls -la'''

def execute(task: ShellCommandTask, ctx: ExecutionContext):
out = task.sh('ps aux', capture=True)
task.io().info(f'Test length: {len(out)}')

return [stdin, compile, execute]


IMPORTS = [
TaskDeclaration(ComposerIntegrationTask(), name=':composer'),
TaskDeclaration(PhpScriptTask(), name=':php'),
ExtendedTaskDeclaration(name=':phpinfo', task=PhpInfoTask),
# ExtendedTaskDeclaration(name=':phpinfo', task=PhpInfoTask),
ExtendedTaskDeclaration(name=':workspace:ls', task=ListWorkspaceFiles)
# ExtendedTaskDeclaration(name=':docs:copy', task=CopyDocsTask),
# ExtendedTaskDeclaration(name=':dist:build', task=PackDistributionTask)
]
Expand Down
3 changes: 3 additions & 0 deletions src/php/tests/samples/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php declare(strict_types=1);

print('Hello world from RKD');

0 comments on commit 86bbf3a

Please sign in to comment.