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

Changes to ease the integration with sphinx-argparse #77

Merged
merged 1 commit into from
Feb 14, 2024
Merged
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
22 changes: 17 additions & 5 deletions wfexs_backend/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from typing import (
Callable,
Sequence,
Tuple,
Type,
Union,
)
Expand Down Expand Up @@ -881,8 +882,11 @@ def processExportCommand(

return retval

def get_wfexs_argparse() -> "argparse.ArgumentParser":
retval, _ = _get_wfexs_argparse_internal(docgen=True)
return retval

def main() -> None:
def _get_wfexs_argparse_internal(docgen: "bool") -> "Tuple[argparse.ArgumentParser, str]":
verstr = get_WfExS_version_str()

defaultLocalConfigFilename = os.environ.get("WFEXS_CONFIG_FILE")
Expand All @@ -894,6 +898,9 @@ def main() -> None:
defaultLocalConfigFilename = os.path.join(
os.getcwd(), defaultLocalConfigFilename
)

rawpre = "" if docgen else "raw|"

ap = argparse.ArgumentParser(
description="WfExS (workflow execution service) backend " + verstr,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
Expand Down Expand Up @@ -958,7 +965,7 @@ def main() -> None:
ap_c = genParserSub(sp, WfExS_Commands.Cache)
ap_c.add_argument(
"cache_command",
help="raw|Cache command to perform\n\n"
help=f"{rawpre}Cache command to perform\n\n"
+ "\n".join(
map(lambda c: f"{c.value:<12}{c.description}", WfExS_Cache_Commands) # type: ignore[attr-defined]
),
Expand Down Expand Up @@ -989,7 +996,7 @@ def main() -> None:
)
ap_c.add_argument(
"cache_type",
help="raw|Cache type to perform the cache command\n\n"
help=f"{rawpre}Cache type to perform the cache command\n\n"
+ "\n".join(map(lambda c: f"{c.value:<12}{c.description}", WfExS_CacheType)), # type: ignore[attr-defined]
type=cast("Callable_WfExS_CacheType", WfExS_CacheType.argtype),
choices=WfExS_CacheType,
Expand All @@ -1001,7 +1008,7 @@ def main() -> None:
ap_w = genParserSub(sp, WfExS_Commands.StagedWorkDir, crateParams=True)
ap_w.add_argument(
"staged_workdir_command",
help="raw|Staged working directory command to perform\n\n"
help=f"{rawpre}Staged working directory command to perform\n\n"
+ "\n".join(
map(
lambda c: f"{c.value:<16}{c.description}", WfExS_Staged_WorkDir_Commands # type: ignore[attr-defined]
Expand Down Expand Up @@ -1032,7 +1039,7 @@ def main() -> None:
)
ap_expt.add_argument(
"export_contents_command",
help="raw|Export operations from staged working directory to perform\n\n"
help=f"{rawpre}Export operations from staged working directory to perform\n\n"
+ "\n".join(
map(lambda c: f"{c.value:<16}{c.description}", WfExS_Export_Commands) # type: ignore[attr-defined]
),
Expand Down Expand Up @@ -1073,6 +1080,11 @@ def main() -> None:
sp, WfExS_Commands.ExportCrate, postStageParams=True, crateParams=True
)

return ap, defaultLocalConfigFilename

def main() -> None:
ap, defaultLocalConfigFilename = _get_wfexs_argparse_internal(docgen=False)

args = ap.parse_args()

fullHelp = args.fullHelp
Expand Down
Loading