Standardisation 3
This commit is contained in:
@@ -50,6 +50,16 @@ def evaluation_parser(description: str) -> argparse.ArgumentParser:
|
||||
return parser
|
||||
|
||||
|
||||
def target_parser(description: str) -> argparse.ArgumentParser:
|
||||
parser = standard_parser(description)
|
||||
parser.add_argument(
|
||||
"target",
|
||||
type=Path,
|
||||
help="Evaluation directory or nested file to process",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def evaluation_workspace(
|
||||
path: str | Path,
|
||||
*,
|
||||
@@ -77,6 +87,21 @@ def workspace_from_args(
|
||||
return evaluation_workspace(args.evaluation, repository=repository)
|
||||
|
||||
|
||||
def workspace_from_target(
|
||||
args: argparse.Namespace,
|
||||
*,
|
||||
repository: str | Path | None = None,
|
||||
) -> tuple[EvaluationWorkspace, Path]:
|
||||
target = Path(args.target).expanduser().resolve()
|
||||
if not target.exists():
|
||||
raise CliError(f"Target does not exist: {target}", ExitCode.INVALID_WORKSPACE)
|
||||
repository_path = Path(repository) if repository is not None else None
|
||||
if target.is_dir() and EvaluationWorkspace.looks_like_evaluation(target):
|
||||
return EvaluationWorkspace(target, repository_path), target
|
||||
workspace = EvaluationWorkspace.discover(target, repository=repository_path)
|
||||
return workspace, target
|
||||
|
||||
|
||||
def execute(
|
||||
parser: argparse.ArgumentParser,
|
||||
argv: Sequence[str] | None,
|
||||
|
||||
Reference in New Issue
Block a user