1+ from __future__ import annotations
2+
13from pathlib import Path
4+ from typing import TYPE_CHECKING
25
36import actionman as _actionman
47import github_contexts as _github_contexts
1417from proman .output import OutputManager
1518from proman .report import Reporter , make_sphinx_target_config
1619
20+ if TYPE_CHECKING :
21+ import argparse
22+
1723
18- def run ():
24+ def run (
25+ path_repo_base : str | Path ,
26+ path_repo_head : str | Path ,
27+ token_github : str ,
28+ token_zenodo : str ,
29+ token_zenodo_sandbox : str ,
30+ github_context : _github_contexts .GitHubContext ,
31+ ):
1932 _logger .section ("Execution" )
2033 event_to_handler = {
2134 _EventType .ISSUES : _handler .IssuesEventHandler ,
@@ -26,18 +39,7 @@ def run():
2639 _EventType .SCHEDULE : _handler .ScheduleEventHandler ,
2740 _EventType .WORKFLOW_DISPATCH : _handler .WorkflowDispatchEventHandler ,
2841 }
29- path_repo_base = _actionman .env_var .read (name = "PATH_REPO_BASE" , typ = str )
30- path_repo_head = _actionman .env_var .read (name = "PATH_REPO_HEAD" , typ = str )
31- admin_token = Token (
32- _actionman .env_var .read (name = "GITHUB_ADMIN_TOKEN" , typ = str ), name = "GitHub Admin"
33- )
34- zenodo_token = Token (_actionman .env_var .read (name = "ZENODO_TOKEN" , typ = str ), name = "Zenodo" )
35- zenodo_sandbox_token = Token (
36- _actionman .env_var .read (name = "ZENODO_SANDBOX_TOKEN" , typ = str ), name = "Zenodo Sandbox"
37- )
38- github_context = _github_contexts .github .create (
39- context = _actionman .env_var .read (name = "GITHUB_CONTEXT" , typ = dict )
40- )
42+
4143 reporter = Reporter (github_context = github_context )
4244 output_writer = OutputManager ()
4345 handler_class = event_to_handler .get (github_context .event_name )
@@ -114,6 +116,37 @@ def run():
114116 return
115117
116118
119+ def run_cli (args : argparse .Namespace ):
120+ """Run the CLI.
121+
122+ Parameters
123+ ----------
124+ args : argparse.Namespace, optional
125+ The parsed arguments. If None, the arguments are parsed from sys.argv.
126+ """
127+ path_repo_base = _actionman .env_var .read (name = "PATH_REPO_BASE" , typ = str )
128+ path_repo_head = _actionman .env_var .read (name = "PATH_REPO_HEAD" , typ = str )
129+ admin_token = Token (
130+ _actionman .env_var .read (name = "GITHUB_ADMIN_TOKEN" , typ = str ), name = "GitHub Admin"
131+ )
132+ zenodo_token = Token (_actionman .env_var .read (name = "ZENODO_TOKEN" , typ = str ), name = "Zenodo" )
133+ zenodo_sandbox_token = Token (
134+ _actionman .env_var .read (name = "ZENODO_SANDBOX_TOKEN" , typ = str ), name = "Zenodo Sandbox"
135+ )
136+ github_context = _github_contexts .github .create (
137+ context = _actionman .env_var .read (name = "GITHUB_CONTEXT" , typ = dict )
138+ )
139+
140+ run (
141+ path_repo_base = path_repo_base ,
142+ path_repo_head = path_repo_head ,
143+ token_github = admin_token ,
144+ token_zenodo = zenodo_token ,
145+ token_zenodo_sandbox = zenodo_sandbox_token ,
146+ github_context = github_context ,
147+ )
148+ return
149+
117150@_logger .sectioner ("Output Generation" )
118151def _finalize (
119152 github_context : _github_contexts .GitHubContext ,
0 commit comments