Release Candidate 1 for the people

This commit is contained in:
Firq 2024-10-05 14:01:50 +02:00
parent 174dd557e5
commit fbda98805f
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
10 changed files with 235 additions and 117 deletions
atlasimagecomposer/cli

View file

@ -1,10 +1,12 @@
import argparse
import pathlib
import sys
from typing import List
from .. import __version__
from ..backend import compose
from ..config import Paths
from ..config import Paths, AtlasDefaults
from ..utils.filesystem import rmdir
# pylint: disable=too-few-public-methods
@ -13,6 +15,9 @@ class Arguments(argparse.Namespace):
Default Arguments when calling the CLI
"""
output: str
cacheclear: bool
filter: List[str]
timeout: int
def parse_arguments():
"""
@ -21,10 +26,15 @@ def parse_arguments():
"""
parser = argparse.ArgumentParser(
prog="atlasimagecomposer",
description="CLI tool to automatically generate expression sheets for servants",)
description="CLI tool to automatically generate expression sheets for servants",
epilog="If there are any issues during execution, it helps to clear the cache from time to time")
parser.add_argument("--output", action="store", type=str, default=None, dest="output", help="Set the output location. This can be an absolute or relative path")
parser.add_argument("--version", action="version", version=f"atlasimagecomposer {__version__}")
parser.add_argument("--output", action="store", type=str, default=None, dest="output", help="Set the output location. This can be an absolute or relative path")
parser.add_argument("--filter", action="extend", nargs="+", dest="filter", help='Specify one or more spritesheet ids that will be fetched')
parser.add_argument("--timeout", action="store", type=int, default=None, dest="timeout", help="Set the timeout for all requests towards AtlasAcademy, default is 10s")
parser.add_argument("--clear-cache", action="store_true", default=False, dest="cacheclear", help="Clear cached assets before downloading files for a servant")
args = Arguments()
args, extra_args = parser.parse_known_args(sys.argv[1:], namespace=args)
@ -36,10 +46,31 @@ def welcome():
print(" developed by Firq ")
print("-------------------------------------------------")
def run():
def run_cli():
args, _ = parse_arguments()
if args.output:
Paths.OUTPUT = pathlib.Path(args.output)
if args.timeout and args.timeout >= 0:
AtlasDefaults.TIMEOUT = args.timeout
welcome()
compose()
servantid = input("Enter servant ID: ")
try:
t = int(servantid)
if t <= 0:
raise ValueError
except ValueError:
print("Servant ID has to be a valid integer above 0")
sys.exit(1)
if args.cacheclear:
cachepath = Paths.IMAGES / str(servantid)
if cachepath.exists():
rmdir(cachepath)
print("Successfully cleared cached assets")
else:
print("No cache to clear was found, continuing")
compose(servantid, args.filter)