Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better --node error message #427

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/convert_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand Down
4 changes: 2 additions & 2 deletions src/feditest/cli/commands/create_constellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand All @@ -42,7 +42,7 @@ def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
parser = parent_parser.add_parser(cmd_name, help='Combine node definitions into a constellation')
parser.add_argument('--name', default=None, required=False, help='Name of the generated constellation')
parser.add_argument('--node', action='append', required=True,
help="Use role=file to specify that the node definition in 'file' is supposed to be used for constellation role 'role'")
help="Use <role>=<file> to specify that the node definition in 'file' is supposed to be used for constellation role 'role'")
parser.add_argument('--out', '-o', default=None, required=False, help='Name of the file for the generated constellation')

return parser
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/create_session_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand Down
4 changes: 2 additions & 2 deletions src/feditest/cli/commands/create_testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand All @@ -45,7 +45,7 @@ def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
parser.add_argument('--constellation', action='append', help='File(s) each containing a JSON fragment defining a constellation')
parser.add_argument('--session', '--session-template', required=False, help='File containing a JSON fragment defining a test session')
parser.add_argument('--node', action='append',
help="Use role=file to specify that the node definition in 'file' is supposed to be used for constellation role 'role'")
help="Use <role>=<file> to specify that the node definition in 'file' is supposed to be used for constellation role 'role'")
parser.add_argument('--filter-regex', default=None, help='Only include tests whose name matches this regular expression')
parser.add_argument('--test', action='append', help='Run this/these named tests(s)')

Expand Down
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def run_info_node_driver(name: str) -> int:
return 1


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand Down
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/list-templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
help = "List the available templates"
parser = parent_parser.add_parser(cmd_name, help=help, description=help)

Expand Down
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/list_nodedrivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand Down
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/list_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:

return 0

def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand Down
4 changes: 2 additions & 2 deletions src/feditest/cli/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand All @@ -109,7 +109,7 @@ def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
parser.add_argument('--constellation', action='append', help='File(s) each containing a JSON fragment defining a constellation')
parser.add_argument('--session', '--session-template', required=False, help='File(s) each containing a JSON fragment defining a test session')
parser.add_argument('--node', action='append',
help="Use role=file to specify that the node definition in 'file' is supposed to be used for constellation role 'role'")
help="Use <role>=<file> to specify that the node definition in 'file' is supposed to be used for constellation role 'role'")
parser.add_argument('--filter-regex', default=None, help='Only include tests whose name matches this regular expression')
parser.add_argument('--test', action='append', help='Run this/these named tests(s)')

Expand Down
2 changes: 1 addition & 1 deletion src/feditest/cli/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int:
return 0


def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None:
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> ArgumentParser:
"""
Add command-line options for this sub-command
parent_parser: the parent argparse parser
Expand Down
2 changes: 2 additions & 0 deletions src/feditest/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def create_constellation_from_nodes(args: Namespace) -> TestPlanConstellation:
roles : dict[str, TestPlanConstellationNode | None] = {}
if args.node:
for nodepair in args.node:
if '=' not in nodepair:
raise ArgumentError(None, 'Syntax error in argument: need --node <role>=<file>')
rolename, nodefile = nodepair.split('=', 1)
if not rolename:
raise ArgumentError(None, f'Rolename component of --node must not be empty: "{ nodepair }".')
Expand Down
Loading