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

20 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-26 17:46 +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.""" 

8import logging 

9import click 

10from flask.cli import with_appcontext 

11import seedboxsync 

12from seedboxsync import create_app 

13from seedboxsync.cli.context import Context 

14from seedboxsync.core import Database 

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__} 

31SeedboxSync database {Database.DATABASE_VERSION}""" 

32 

33 

34@click.group( 

35 "seedboxsync", 

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

37 cls=Cli, 

38 context_settings=CONTEXT_SETTINGS, 

39 create_app=create_app, 

40 no_args_is_help=True, 

41 add_default_commands=False, 

42 add_version_option=False, 

43 load_dotenv=False, 

44) 

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

46@pass_context 

47@with_appcontext 

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

49 """ 

50 SeedboxSync CLI entrypoint. 

51 

52 Args: 

53 ctx (Context): The Click context object. 

54 """ 

55 check_root_warning() 

56 if ctx.app.debug: 

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

58 else: 

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