From 8f3083358f3dc5b6f114f32c061259c659224a09 Mon Sep 17 00:00:00 2001 From: Jan Wielemaker Date: Wed, 20 Nov 2024 10:25:05 +0100 Subject: [PATCH] Better option handling in demo server --- src/wasm/server.pl | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/wasm/server.pl b/src/wasm/server.pl index d7de2b2130..2a83964452 100644 --- a/src/wasm/server.pl +++ b/src/wasm/server.pl @@ -3,7 +3,7 @@ Author: Jan Wielemaker E-mail: J.Wielemaker@vu.nl WWW: http://www.swi-prolog.org - Copyright (c) 2022-20244, SWI-Prolog Solutions b.v. + Copyright (c) 2022-2024, SWI-Prolog Solutions b.v. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -79,17 +79,24 @@ :- endif. -:- initialization(server_loop, main). +:- initialization(main, main). + +opt_type(port, port, nonneg). +opt_type(p, port, nonneg). +opt_type(interactive, interactive, boolean). +opt_type(i, i, boolean). -opt_type(port, port, nonneg). opt_help(port, "Port to listen to (default 8080)"). +opt_help(interactive, "Become interactive"). -server :- - current_prolog_flag(argv, Argv), - argv_options(Argv, _Positonal, Options), +server(Options) :- merge_options(Options, [port(8080)], Options1), http_server(Options1). -server_loop :- - server, - thread_get_message(quit). +main(Argv) :- + argv_options(Argv, _Pos, Options), + server(Options), + ( option(interactive(true), Options) + -> cli_enable_development_system + ; thread_get_message(quit) + ).