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

Commit

Permalink
#16: Show full task description in --help
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Jun 11, 2020
1 parent 5024d84 commit 0930488
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/rkd/argparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def add_env_variables_to_argparse(cls, argparse: ArgumentParser, task: TaskDecla
if argparse.description is None:
argparse.description = ""

argparse.description += task.get_full_description() + "\n"

# print all environment variables possible to use
argparse.description += "\nEnvironment variables for task \"%s\":\n" % task.to_full_name()

Expand Down
10 changes: 9 additions & 1 deletion src/rkd/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def get_task_name(self) -> str:
def get_description(self) -> str:
pass

@abstractmethod
def get_full_description(self) -> str:
pass


class GroupDeclarationInterface(AbstractClass):
@abstractmethod
Expand Down Expand Up @@ -85,7 +89,8 @@ def find_all_tasks(self) -> Dict[str, Union[TaskDeclarationInterface, GroupDecla

class ExecutorInterface(AbstractClass):
@abstractmethod
def execute(self, task: TaskDeclarationInterface, parent: Union[GroupDeclarationInterface, None] = None, args: list = []):
def execute(self, task: TaskDeclarationInterface, task_num: int,
parent: Union[GroupDeclarationInterface, None] = None, args: list = []):
pass


Expand Down Expand Up @@ -252,3 +257,6 @@ def table(header: list, body: list, tablefmt: str= "simple",
disable_numparse: bool = False,
colalign: str = None):

return tabulate(body, headers=header, floatfmt=floatfmt, numalign=numalign, tablefmt=tablefmt,
stralign=stralign, missingval=missingval, showindex=showindex,
disable_numparse=disable_numparse, colalign=colalign)
8 changes: 8 additions & 0 deletions src/rkd/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def get_description(self) -> str:

return task.__doc__.strip().split("\n")[0]

def get_full_description(self) -> str:
task = self.get_task_to_execute()

if task.get_description():
return task.get_description()

return task.__doc__.strip()

@staticmethod
def parse_name(name: str) -> tuple:
split = name.split(':')
Expand Down

0 comments on commit 0930488

Please sign in to comment.