Skip to content

Commit af88be5

Browse files
committed
Improved the usage prompt when Plato is run without errors in arguments, or without any argument.
1 parent 7c9260c commit af88be5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

plato/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def construct_include(loader: Loader, node: yaml.Node) -> Any:
5151
def __new__(cls):
5252
if cls._instance is None:
5353
parser = argparse.ArgumentParser()
54+
if not parser.prog.startswith("uv run "):
55+
parser.prog = f"uv run {parser.prog}"
5456
parser.add_argument("-i", "--id", type=str, help="Unique client ID.")
5557
parser.add_argument(
5658
"-p", "--port", type=str, help="The port number for running a server."
@@ -125,8 +127,11 @@ def __new__(cls):
125127
with open(filename, "r", encoding="utf-8") as config_file:
126128
config = yaml.load(config_file, Loader)
127129
else:
128-
# if the configuration file does not exist, raise an error
129-
raise ValueError("A configuration file must be supplied.")
130+
usage = parser.format_usage().strip()
131+
raise SystemExit(
132+
"Please provide a configuration file using the '-c' option.\n"
133+
f"{usage}"
134+
)
130135

131136
Config.clients = Config.namedtuple_from_dict(config["clients"])
132137
Config.server = Config.namedtuple_from_dict(config["server"])

0 commit comments

Comments
 (0)