Skip to content

Make line numbers the default behavior for gpt-copy#23

Merged
simone-viozzi merged 4 commits intomainfrom
copilot/fix-20
Jun 27, 2025
Merged

Make line numbers the default behavior for gpt-copy#23
simone-viozzi merged 4 commits intomainfrom
copilot/fix-20

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 27, 2025

This PR makes line numbers enabled by default for gpt-copy, as requested in the issue. Line numbers are useful for referencing specific parts of files when working with LLMs, so they should be on by default.

Changes Made

Core Functionality

  • Line numbers are now enabled by default - no flag required
  • Added --no-number flag to disable line numbers when needed
  • Kept -n/--number flag for backward compatibility
  • --no-number takes precedence over -n if both are specified

Before vs After

Before (line numbers off by default):

gpt-copy /path/to/directory           # No line numbers
gpt-copy /path/to/directory -n        # Line numbers enabled

After (line numbers on by default):

gpt-copy /path/to/directory           # Line numbers enabled by default
gpt-copy /path/to/directory -n        # Line numbers enabled (redundant but supported)
gpt-copy /path/to/directory --no-number  # Line numbers disabled

Documentation Updates

  • Updated README.md to reflect new default behavior
  • Updated help text to show line numbers are enabled by default
  • Updated "How It Works" section and feature list

Testing

  • Added comprehensive tests for the new default behavior
  • All existing tests continue to pass (24/24 tests passing)
  • Backward compatibility maintained

Example Output

With line numbers now enabled by default:

## File: `example.py`
*(Relative Path: `example.py`)*

```python
1: def hello():
2:     print("Hello, World!")
3:     return True

Fixes #20.

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey.

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
Copilot AI changed the title [WIP] make -n the defalut, line numbers are useful, they should be on by default Make line numbers the default behavior for gpt-copy Jun 27, 2025
Copilot AI requested a review from simone-viozzi June 27, 2025 17:52
@@ -502,17 +502,26 @@ def write_output(
@click.option(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the -n altogether

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the -n flag completely as requested. Line numbers are now enabled by default with only --no-number to disable them when needed. This simplifies the interface since the -n flag was redundant. (ae95b81)

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
readme.md Outdated
gpt-copy /path/to/directory --no-number
```

**Explicitly enable line numbers (redundant, but supported for backward compatibility):**
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not present anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the redundant -n flag documentation section. (f59c4fb)

**Disable line numbers:**
```sh
gpt-copy /path/to/directory --no-number
```
Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Contributor Author

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)

no_line_numbers (bool): If True, disable line numbers.
"""
# Line numbers are enabled by default, --no-number disables them
use_line_numbers = not no_line_numbers
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to line 544 and remove comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the line numbers logic inline and removed the comment as requested. (f59c4fb)

…e numbers logic inline

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
@simone-viozzi
Copy link
Copy Markdown
Owner

LGTM you can merge the PR

@simone-viozzi simone-viozzi marked this pull request as ready for review June 27, 2025 18:56
@simone-viozzi simone-viozzi merged commit b375eb8 into main Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants