Coverage for seedboxsync/cli/__init__.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-26 17:14 +0000

1# 

2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr> 

3# 

4# For the full copyright and license information, please view the LICENSE 

5# file that was distributed with this source code. 

6# 

7"""CLI package using Click framework.""" 

8 

9import logging 

10import click 

11from flask.cli import with_appcontext 

12import seedboxsync 

13from seedboxsync import create_app 

14from seedboxsync.cli.context import Context 

15from .cli import Cli, check_root_warning, command, group, pass_context 

16 

17__all__ = [ 

18 "Cli", 

19 "Context", 

20 "command", 

21 "group", 

22 "pass_context", 

23] 

24 

25CONTEXT_SETTINGS = { 

26 "help_option_names": ["-h", "--help"], 

27} 

28VERSION_BANNER = f"""Script for performing sync operations between your NAS and your seedbox. 

29 

30SeedboxSync {seedboxsync.__version__}""" 

31 

32 

33@click.group( 

34 "seedboxsync", 

35 help="Script for sync operations between your NAS and your seedbox", 

36 cls=Cli, 

37 context_settings=CONTEXT_SETTINGS, 

38 create_app=create_app, 

39 no_args_is_help=True, 

40 add_default_commands=False, 

41 add_version_option=False, 

42 load_dotenv=False, 

43) 

44@click.version_option(version=seedboxsync.__version__, prog_name="SeedboxSync", message=VERSION_BANNER) 

45@pass_context 

46@with_appcontext 

47def cli(ctx: Context) -> None: 

48 """ 

49 SeedboxSync CLI entrypoint. 

50 

51 Args: 

52 ctx (Context): The Click context object. 

53 """ 

54 check_root_warning() 

55 if ctx.app.debug: 

56 ctx.app.logger.setLevel(logging.DEBUG) 

57 else: 

58 ctx.app.logger.setLevel(logging.INFO)