Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Added __version__ and --version switch (issue #318) #319

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data_diff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .joindiff_tables import JoinDiffer
from .table_segment import TableSegment

__version__ = "0.3.0rc4"

def connect_to_table(
db_info: Union[str, dict],
Expand Down
8 changes: 7 additions & 1 deletion data_diff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .parse_time import parse_time_before_now, UNITS_STR, ParseError
from .config import apply_config_from_file
from .tracking import disable_tracking
from . import __version__


LOG_FORMAT = "[%(asctime)s] %(levelname)s - %(message)s"
Expand Down Expand Up @@ -76,7 +77,7 @@ def __init__(self, **kwargs):
self.indent_increment = 6

def write_usage(self, prog: str, args: str = "", prefix: Optional[str] = None) -> None:
self.write("data-diff - efficiently diff rows across database tables.\n\n")
self.write(f"data-diff v{__version__} - efficiently diff rows across database tables.\n\n")
self.write("Usage:\n")
self.write(f" * In-db diff: {prog} <database1> <table1> <table2> [OPTIONS]\n")
self.write(f" * Cross-db diff: {prog} <database1> <table1> <database2> <table2> [OPTIONS]\n")
Expand Down Expand Up @@ -140,6 +141,7 @@ def write_usage(self, prog: str, args: str = "", prefix: Optional[str] = None) -
@click.option("-d", "--debug", is_flag=True, help="Print debug info")
@click.option("--json", "json_output", is_flag=True, help="Print JSONL output for machine readability")
@click.option("-v", "--verbose", is_flag=True, help="Print extra info")
@click.option("--version", is_flag=True, help="Print version info and exit")
@click.option("-i", "--interactive", is_flag=True, help="Confirm queries, implies --debug")
@click.option("--no-tracking", is_flag=True, help="data-diff sends home anonymous usage data. Use this to disable it.")
@click.option(
Expand Down Expand Up @@ -233,6 +235,7 @@ def _main(
stats,
debug,
verbose,
version,
interactive,
no_tracking,
threads,
Expand All @@ -248,6 +251,9 @@ def _main(
threads2=None,
__conf__=None,
):
if version:
print(f"v{__version__}")
return

if no_tracking:
disable_tracking()
Expand Down