Skip to content

Commit 2516a3e

Browse files
authored
better terminal width detection
1 parent 000f875 commit 2516a3e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

db_diff/cli.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
import os
55
import datetime
66
import csv
7+
import shutil # Add this import
78
from . import load_csv, load_json, compare, human_text, streaming_compare_csv
89

10+
# Get terminal width for better help formatting
11+
TERMINAL_WIDTH = shutil.get_terminal_size().columns
12+
913
DIALECTS = {
1014
"csv": "excel",
1115
"tsv": "excel-tab",
@@ -45,7 +49,10 @@ def load(filename, key, input_format, encoding="utf-8"):
4549
raise click.ClickException(f"Failed to load '{filename}': {e}")
4650

4751
@click.command(
48-
context_settings={"help_option_names": ["-h", "--help"]},
52+
context_settings={
53+
"help_option_names": ["-h", "--help"],
54+
"max_content_width": TERMINAL_WIDTH # Set the max width to terminal width
55+
},
4956
help="Compare the differences between two CSV or JSON files to find differences.",
5057
epilog="Example: db-diff old.csv new.csv --key=Id --output=jsonfile --outfilename=diff.json",
5158
no_args_is_help=True,

0 commit comments

Comments
 (0)