mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 02:38:30 +02:00
cli now support arguments (removed the old input method) and raise error if one of them is invalid.
This commit is contained in:
parent
de5421cfdf
commit
8bf935a5cc
1 changed files with 13 additions and 19 deletions
|
@ -18,24 +18,24 @@ def cli(options, argparser: argparse.ArgumentParser):
|
||||||
|
|
||||||
mod_config_path = Path(f"./Pack/{args.mod}/mod_config.json")
|
mod_config_path = Path(f"./Pack/{args.mod}/mod_config.json")
|
||||||
if not mod_config_path.exists():
|
if not mod_config_path.exists():
|
||||||
print(_("ERROR_INVALID_MOD") % args.mod, file=sys.stderr)
|
sys.stderr.write(_("ERROR_INVALID_MOD") % args.mod + "\n")
|
||||||
return
|
return
|
||||||
mod_config = ModConfig.from_file(mod_config_path)
|
mod_config = ModConfig.from_file(mod_config_path)
|
||||||
|
|
||||||
game_path = Path(args.source)
|
game_path = Path(args.source)
|
||||||
if not is_valid_source_path(game_path):
|
if not is_valid_source_path(game_path):
|
||||||
print(_("ERROR_INVALID_SOURCE_GAME") % game_path, file=sys.stderr)
|
sys.stderr.write(_("ERROR_INVALID_SOURCE_GAME") % game_path + "\n")
|
||||||
return
|
return
|
||||||
game = Game(args.source)
|
game = Game(args.source)
|
||||||
|
|
||||||
destination_path = Path(args.dest)
|
destination_path = Path(args.dest)
|
||||||
if not is_valid_destination_path(destination_path):
|
if not is_valid_destination_path(destination_path):
|
||||||
print(_("ERROR_INVALID_GAME_DESTINATION") % destination_path, file=sys.stderr)
|
sys.stderr.write(_("ERROR_INVALID_GAME_DESTINATION") % destination_path + "\n")
|
||||||
return
|
return
|
||||||
|
|
||||||
try: output_type = Extension[args.output_type]
|
try: output_type = Extension[args.output_type]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print(_("ERROR_INVALID_OUTPUT_TYPE") % args.output_type, file=sys.stderr)
|
sys.stderr.write(_("ERROR_INVALID_OUTPUT_TYPE") % args.output_type + "\n")
|
||||||
return
|
return
|
||||||
|
|
||||||
# installation and progress bar
|
# installation and progress bar
|
||||||
|
@ -67,21 +67,15 @@ def cli(options, argparser: argparse.ArgumentParser):
|
||||||
|
|
||||||
progressbar_step: int = current_step * progressbar_max // max_step if max_step > 0 else 0
|
progressbar_step: int = current_step * progressbar_max // max_step if max_step > 0 else 0
|
||||||
|
|
||||||
print(
|
sys.stdout.write(
|
||||||
"\033[H\033[J", "\n", # clear the shell
|
"\033[H\033[J" # clear the shell
|
||||||
title, f"({current_part} / {max_part})", "\n", # print the title and the actual part
|
f"{title} ({current_part} / {max_part})\n" # print the title and the actual part
|
||||||
description, "\n", # print the description
|
f"{description}\n" # print the description
|
||||||
*((
|
|
||||||
f"{round((current_step / max_step if max_step > 0 else 0) * 100, 2)}% "
|
|
||||||
f"[{'#' * progressbar_step}{' ' * (progressbar_max - progressbar_step)}]"
|
|
||||||
) if determinate else ()), # if determinate, show a progress bar
|
|
||||||
|
|
||||||
sep=""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(
|
if determinate: sys.stdout.write(
|
||||||
"\033[H\033[J",
|
f"{round((current_step / max_step if max_step > 0 else 0) * 100, 2)}% "
|
||||||
get_finished_installation_message(mod_config),
|
f"[{'#' * progressbar_step}{' ' * (progressbar_max - progressbar_step)}]\n"
|
||||||
|
)
|
||||||
|
|
||||||
sep="\n"
|
sys.stdout.write("\033[H\033[J" + get_finished_installation_message(mod_config) + "\n")
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue