Skip to content

Commit

Permalink
remove obscure --eof-newline/--no-eof-newline cli option. Have a conf…
Browse files Browse the repository at this point in the history
…ig option is enough.
  • Loading branch information
SmileyChris committed Apr 25, 2024
1 parent f672dbc commit 9fe507e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
13 changes: 2 additions & 11 deletions src/towncrier/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
default=DEFAULT_CONTENT,
help="Sets the content of the new fragment.",
)
@click.option(
"--eof-newline/--no-eof-newline",
default=None,
help="Ensure the content ends with an empty line.",
)
@click.argument("filename", default="")
def _main(
ctx: click.Context,
Expand All @@ -58,7 +53,6 @@ def _main(
filename: str,
edit: bool | None,
content: str,
eof_newline: bool | None,
) -> None:
"""
Create a new news fragment.
Expand All @@ -76,7 +70,7 @@ def _main(
* .removal - a deprecation or removal of public API,
* .misc - a ticket has been closed, but it is not of interest to users.
"""
__main(ctx, directory, config, filename, edit, content, eof_newline)
__main(ctx, directory, config, filename, edit, content)


def __main(
Expand All @@ -86,14 +80,11 @@ def __main(
filename: str,
edit: bool | None,
content: str,
eof_newline: bool | None,
) -> None:
"""
The main entry point.
"""
base_directory, config = load_config_from_options(directory, config_path)
if eof_newline is None:
eof_newline = config.create_eof_newline

filename_ext = ""
if config.create_add_extension:
Expand Down Expand Up @@ -178,7 +169,7 @@ def __main(

with open(segment_file, "w") as f:
f.write(content)
if eof_newline and content and not content.endswith("\n"):
if config.create_eof_newline and content and not content.endswith("\n"):
f.write("\n")

click.echo(f"Created news fragment at {segment_file}")
Expand Down
2 changes: 1 addition & 1 deletion src/towncrier/newsfragments/482.feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ If no filename is given when doing ``towncrier`` create, interactively ask for t

Now by default, when creating a fragment it will be appended with the ``filename`` option's extension (unless an extension is explicitly provided). For example, ``towncrier create 123.feature`` will create ``news/123.feature.rst``. This can be changed in configuration file by setting `add_extension = false`.

A new line is now added by default to the end of the fragment contents. This can be reverted in the configuration file by setting `add_newline = false` or explicitly set with the ``create`` command line flags ``--eof-newline/--no-eof-newline``.
A new line is now added by default to the end of the fragment contents. This can be reverted in the configuration file by setting `add_newline = false`.
13 changes: 0 additions & 13 deletions src/towncrier/test/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ def test_content_without_eof_newline(self):
eof_newline=False,
)

def test_content_no_eof_newline_arg(self):
"""
When creating a new fragment the content can be passed as a command line
argument. The text editor is not invoked, and no eof newline is added if the
--no-eof-newline argument is passed.
"""
content_line = "This is a content"
self._test_success(
content=[content_line],
additional_args=["-c", content_line, "--no-eof-newline"],
eof_newline=False,
)

def test_message_and_edit(self):
"""
When creating a new message, a initial content can be passed via
Expand Down

0 comments on commit 9fe507e

Please sign in to comment.