diff --git a/mysql_to_sqlite3/__init__.py b/mysql_to_sqlite3/__init__.py index 8cc9d70..4567199 100644 --- a/mysql_to_sqlite3/__init__.py +++ b/mysql_to_sqlite3/__init__.py @@ -1,4 +1,4 @@ """Utility to transfer data from MySQL to SQLite 3.""" -__version__ = "2.1.7" +__version__ = "2.1.8" from .transporter import MySQLtoSQLite diff --git a/mysql_to_sqlite3/cli.py b/mysql_to_sqlite3/cli.py index 7f7dc60..f74f73c 100644 --- a/mysql_to_sqlite3/cli.py +++ b/mysql_to_sqlite3/cli.py @@ -2,17 +2,27 @@ import os import sys import typing as t +from datetime import datetime import click from tabulate import tabulate from . import MySQLtoSQLite +from . import __version__ as package_version from .click_utils import OptionEatAll, prompt_password, validate_positive_integer from .debug_info import info from .sqlite_utils import CollatingSequences -@click.command() +_copyright_header: str = f"mysql2sqlite version {package_version} Copyright (c) 2019-{datetime.now().year} Klemen Tusar" + + +@click.command( + name="mysql2sqlite", + help=_copyright_header, + no_args_is_help=True, + epilog="For more information, visit https://github.com/techouse/mysql-to-sqlite3", +) @click.option( "-f", "--sqlite-file", @@ -141,6 +151,7 @@ def cli( debug: bool, ) -> None: """Transfer MySQL to SQLite using the provided CLI options.""" + click.echo(_copyright_header) try: if mysql_tables and exclude_mysql_tables: raise click.UsageError("Illegal usage: --mysql-tables and --exclude-mysql-tables are mutually exclusive!") diff --git a/tests/func/test_cli.py b/tests/func/test_cli.py index 98cd0ef..a050f85 100644 --- a/tests/func/test_cli.py +++ b/tests/func/test_cli.py @@ -1,5 +1,6 @@ import os import typing as t +from datetime import datetime from random import choice, sample import pytest @@ -9,6 +10,7 @@ from sqlalchemy import Connection, Engine, Inspector, create_engine, inspect from mysql_to_sqlite3 import MySQLtoSQLite +from mysql_to_sqlite3 import __version__ as package_version from mysql_to_sqlite3.cli import cli as mysql2sqlite from tests.conftest import MySQLCredentials from tests.database import Database @@ -19,12 +21,12 @@ class TestMySQLtoSQLite: def test_no_arguments(self, cli_runner: CliRunner) -> None: result: Result = cli_runner.invoke(mysql2sqlite) - assert result.exit_code > 0 - assert any( + assert result.exit_code == 0 + assert all( message in result.output for message in { - 'Error: Missing option "-f" / "--sqlite-file"', - "Error: Missing option '-f' / '--sqlite-file'", + f"Usage: {mysql2sqlite.name} [OPTIONS]", + f"{mysql2sqlite.name} version {package_version} Copyright (c) 2019-{datetime.now().year} Klemen Tusar", } ) @@ -332,10 +334,14 @@ def test_minimum_valid_parameters( arguments.append("-q") result: Result = cli_runner.invoke(mysql2sqlite, arguments) assert result.exit_code == 0 + copyright_header = ( + f"{mysql2sqlite.name} version {package_version} Copyright (c) 2019-{datetime.now().year} Klemen Tusar\n" + ) + assert copyright_header in result.output if quiet: - assert result.output == "" + assert result.output.replace(copyright_header, "") == "" else: - assert result.output != "" + assert result.output.replace(copyright_header, "") != "" def test_keyboard_interrupt( self,