-
Notifications
You must be signed in to change notification settings - Fork 0
Make line numbers the default behavior for gpt-copy #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4337ba6
39d1b6d
ae95b81
f59c4fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -500,19 +500,19 @@ def write_output( | |
| help="Glob pattern(s) to exclude files (e.g., 'src/tests/*')", | ||
| ) | ||
| @click.option( | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the -n altogether
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the |
||
| "-n", | ||
| "--number", | ||
| "line_numbers", | ||
| "--no-number", | ||
| "no_line_numbers", | ||
| is_flag=True, | ||
| help="Add line numbers to file content.", | ||
| default=False, | ||
| help="Disable line numbers for file content.", | ||
| ) | ||
| def main( | ||
| root_path: Path, | ||
| output_file: str | None, | ||
| force: bool, | ||
| include_patterns: tuple[str, ...], | ||
| exclude_patterns: tuple[str, ...], | ||
| line_numbers: bool, | ||
| no_line_numbers: bool, | ||
| ) -> None: | ||
| """ | ||
| Main function to start the script. | ||
|
|
@@ -523,8 +523,9 @@ def main( | |
| force (bool): If True, ignore .gitignore and Git-tracked files. | ||
| include_patterns (Tuple[str, ...]): The tuple of include glob patterns. | ||
| exclude_patterns (Tuple[str, ...]): The tuple of exclude glob patterns. | ||
| line_numbers (bool): If True, add line numbers to the file contents. | ||
| no_line_numbers (bool): If True, disable line numbers. | ||
| """ | ||
|
|
||
| root_path = root_path.resolve() | ||
| print(f"Starting script for directory: {root_path}", file=sys.stderr) | ||
| gitignore_specs, tracked_files = get_ignore_settings(root_path, force) | ||
|
|
@@ -538,7 +539,7 @@ def main( | |
| tracked_files, | ||
| include_patterns=list(include_patterns), | ||
| exclude_patterns=list(exclude_patterns), | ||
| line_numbers=line_numbers, | ||
| line_numbers=not no_line_numbers, | ||
| ) | ||
|
|
||
| if output_file: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| test content |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """Test that line numbers are enabled by default.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from click.testing import CliRunner | ||
| from gpt_copy.gpt_copy import main | ||
|
|
||
|
|
||
| def test_line_numbers_enabled_by_default(tmp_path: Path): | ||
| """Test that line numbers are enabled by default without -n flag.""" | ||
| # Create a test file with multiple lines | ||
| test_file = tmp_path / "test.txt" | ||
| test_file.write_text("line one\nline two\nline three\n", encoding="utf-8") | ||
|
|
||
| runner = CliRunner() | ||
| result = runner.invoke(main, [tmp_path.as_posix()]) | ||
|
|
||
| assert result.exit_code == 0 | ||
| # Check that line numbers are present in the output | ||
| assert "1: line one" in result.output | ||
| assert "2: line two" in result.output | ||
| assert "3: line three" in result.output | ||
|
|
||
|
|
||
| def test_no_number_flag_disables_line_numbers(tmp_path: Path): | ||
| """Test that --no-number flag disables line numbers.""" | ||
| # Create a test file with multiple lines | ||
| test_file = tmp_path / "test.txt" | ||
| test_file.write_text("line one\nline two\nline three\n", encoding="utf-8") | ||
|
|
||
| runner = CliRunner() | ||
| result = runner.invoke(main, [tmp_path.as_posix(), "--no-number"]) | ||
|
|
||
| assert result.exit_code == 0 | ||
| # Check that line numbers are NOT present in the output | ||
| assert "1: line one" not in result.output | ||
| assert "2: line two" not in result.output | ||
| assert "3: line three" not in result.output | ||
| # But the content should still be there | ||
| assert "line one" in result.output | ||
| assert "line two" in result.output | ||
| assert "line three" in result.output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since line numbers are enabled by default, word it differently,
do an example to disable the line numers, and do not mention how to enable them, since they are already enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the documentation to focus only on disabling line numbers since they're now enabled by default. Removed the section about enabling them explicitly. (f59c4fb)