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

Launcher: explicitly handle cli arguments to be passed to the Component #3714

Merged
merged 9 commits into from
Sep 8, 2024
4 changes: 2 additions & 2 deletions CommonClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ async def main(args):
parser = get_base_parser(description="Gameless Archipelago Client, for text interfacing.")
parser.add_argument('--name', default=None, help="Slot Name to connect as.")
parser.add_argument("url", nargs="?", help="Archipelago connection url")
args = parser.parse_args(args if args else None) # this is necessary as long as CommonClient itself is launchable
args = parser.parse_args(args)

if args.url:
url = urllib.parse.urlparse(args.url)
Expand All @@ -1053,4 +1053,4 @@ async def main(args):

if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO) # force log-level to work around log level resetting to WARNING
run_as_textclient()
run_as_textclient(*sys.argv[1:]) # default value for parse_args
5 changes: 4 additions & 1 deletion Launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ def main(args: Optional[Union[argparse.Namespace, dict]] = None):
init_logging('Launcher')
Utils.freeze_support()
multiprocessing.set_start_method("spawn") # if launched process uses kivy, fork won't work
parser = argparse.ArgumentParser(description='Archipelago Launcher')
parser = argparse.ArgumentParser(
description='Archipelago Launcher',
usage="[-h] [--update_settings] [Patch|Game|Component] [-- component args here]"
)
run_group = parser.add_argument_group("Run")
run_group.add_argument("--update_settings", action="store_true",
help="Update host.yaml and exit.")
Expand Down
4 changes: 2 additions & 2 deletions worlds/LauncherComponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __repr__(self):
processes = weakref.WeakSet()


def launch_subprocess(func: Callable, name: str = None, args: Tuple[str, ...] = ()):
def launch_subprocess(func: Callable, name: str = None, args: Tuple[str, ...] = ()) -> None:
global processes
import multiprocessing
process = multiprocessing.Process(target=func, name=name, args=args)
Expand All @@ -85,7 +85,7 @@ def __call__(self, path: str) -> bool:

def launch_textclient(*args):
NewSoupVi marked this conversation as resolved.
Show resolved Hide resolved
import CommonClient
launch_subprocess(CommonClient.run_as_textclient, "TextClient", args)
launch_subprocess(CommonClient.run_as_textclient, name="TextClient", args=args)


def _install_apworld(apworld_src: str = "") -> Optional[Tuple[pathlib.Path, pathlib.Path]]:
Expand Down
Loading