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

Support python direct call _parse_args or run #1000

Merged
merged 1 commit into from
Jul 15, 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
8 changes: 4 additions & 4 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,9 +1713,9 @@ def get_podman_args(self, cmd):
xargs.extend(shlex.split(args))
return xargs

async def run(self):
async def run(self, argv=None):
log.info("podman-compose version: %s", __version__)
args = self._parse_args()
args = self._parse_args(argv)
podman_path = args.podman_path
if podman_path != "podman":
if os.path.isfile(podman_path) and os.access(podman_path, os.X_OK):
Expand Down Expand Up @@ -2023,7 +2023,7 @@ def _resolve_profiles(self, defined_services, requested_profiles=None):
services[name] = config
return services

def _parse_args(self):
def _parse_args(self, argv=None):
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
self._init_global_parser(parser)
subparsers = parser.add_subparsers(title="command", dest="command")
Expand All @@ -2032,7 +2032,7 @@ def _parse_args(self):
subparser = subparsers.add_parser(cmd_name, help=cmd.desc) # pylint: disable=protected-access
for cmd_parser in cmd._parse_args: # pylint: disable=protected-access
cmd_parser(subparser)
self.global_args = parser.parse_args()
self.global_args = parser.parse_args(argv)
if self.global_args.in_pod is not None and self.global_args.in_pod.lower() not in (
'',
'true',
Expand Down