Album skeleton creation
This commit is contained in:
parent
4e6cf1d499
commit
e3816dfdb7
8 changed files with 85 additions and 29 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import logging
|
||||
from argparse import ArgumentParser, Namespace
|
||||
from pathlib import Path
|
||||
|
||||
from photoalbum.config import DEFAULT_CONFIG_PATH, Config
|
||||
from photoalbum.generate import generate
|
||||
|
||||
logger = logging.getLogger("photoalbum.cli")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
setup_logging(args.logging)
|
||||
# TODO: load config from file
|
||||
config = Config()
|
||||
|
||||
|
|
@ -18,6 +22,28 @@ def main() -> None:
|
|||
cmd_clean(args, config)
|
||||
|
||||
|
||||
########################################
|
||||
# Command functions
|
||||
def cmd_init(args: Namespace, config: Config) -> None:
|
||||
"""
|
||||
Generate a basic config and template files
|
||||
"""
|
||||
|
||||
|
||||
def cmd_generate(args: Namespace, config: Config) -> None:
|
||||
logger.debug(f"Generating in {args.path}")
|
||||
generate(config, Path(args.path))
|
||||
|
||||
|
||||
def cmd_clean(args: Namespace, config: Config) -> None:
|
||||
"""
|
||||
Clean the photo album by all files that photoalbum generated
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
########################################
|
||||
# CLI Util functions
|
||||
def parse_args() -> Namespace:
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
|
|
@ -26,6 +52,12 @@ def parse_args() -> Namespace:
|
|||
default=DEFAULT_CONFIG_PATH,
|
||||
help="Path to photoalbum.config.json for the album",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--logging",
|
||||
default="warning",
|
||||
choices=[level.lower() for level in logging.getLevelNamesMapping().keys()],
|
||||
help="Log level",
|
||||
)
|
||||
|
||||
subcommands = parser.add_subparsers(title="subcommands")
|
||||
|
||||
|
|
@ -52,21 +84,10 @@ def parse_args() -> Namespace:
|
|||
return parser.parse_args()
|
||||
|
||||
|
||||
def cmd_init(args: Namespace, config: Config) -> None:
|
||||
"""
|
||||
Generate a basic config and template files
|
||||
"""
|
||||
|
||||
|
||||
def cmd_generate(args: Namespace, config: Config) -> None:
|
||||
generate(config, Path(args.path))
|
||||
|
||||
|
||||
def cmd_clean(args: Namespace, config: Config) -> None:
|
||||
"""
|
||||
Clean the photo album by all files that photoalbum generated
|
||||
"""
|
||||
pass
|
||||
def setup_logging(level: str) -> None:
|
||||
levels = logging.getLevelNamesMapping()
|
||||
# TODO: Set up a better formatter with date/time and stuff
|
||||
logging.basicConfig(level=levels[level.upper()])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue