mirror of
https://github.com/Ryujinx/Ryujinx-Mako.git
synced 2024-12-23 00:25:39 +00:00
66a1029bd5
* Create multiple actions to make Mako easier to use * Add smoke tests for the new actions * Check if the required env vars aren't empty * Fix working directory for execute-command * Fix action_path references * Fix broken setup_git command * Add exec-ryujinx-tasks subcommand * Ensure python and pipx are installed * Improve help output * Add required environment variables to README.md * Add small script to generate subcommand sections automatically * Adjust help messages for ryujinx tasks as well * Remove required argument for positionals * Add exec-ryujinx-tasks to subcommands list * Apply black formatting * Fix event name for update-reviewers
54 lines
1.3 KiB
Python
Executable file
54 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
import os
|
|
import re
|
|
import subprocess
|
|
from typing import Union
|
|
|
|
|
|
def run_mako_command(command: Union[str, list[str]]) -> str:
|
|
subprocess_cmd = ["poetry", "run", "ryujinx-mako"]
|
|
|
|
if isinstance(command, str):
|
|
subprocess_cmd.append(command)
|
|
elif isinstance(command, list):
|
|
subprocess_cmd.extend(command)
|
|
else:
|
|
raise TypeError(command)
|
|
|
|
env = os.environ.copy()
|
|
env["MAKO_DRY_RUN"] = "1"
|
|
|
|
process = subprocess.run(
|
|
subprocess_cmd, stdout=subprocess.PIPE, check=True, env=env
|
|
)
|
|
|
|
return process.stdout.decode()
|
|
|
|
|
|
def print_help(name: str, output: str, level=3):
|
|
headline_prefix = "#" * level
|
|
print(f"{headline_prefix} {name}\n")
|
|
print("```")
|
|
print(output.rstrip())
|
|
print("```\n")
|
|
|
|
|
|
general_help = run_mako_command("--help")
|
|
for line in general_help.splitlines():
|
|
subcommands = re.match(r" {2}\{(.+)}", line)
|
|
if subcommands:
|
|
break
|
|
else:
|
|
subcommands = None
|
|
|
|
if not subcommands:
|
|
print("Could not find subcommands in general help output:")
|
|
print(general_help)
|
|
exit(1)
|
|
|
|
subcommands = subcommands.group(1).split(",")
|
|
|
|
print_help("Available commands", general_help, 2)
|
|
for subcommand in subcommands:
|
|
print_help(subcommand, run_mako_command([subcommand, "--help"]))
|