Skip to content

Commit 07baa2b

Browse files
authored
Merge pull request #395 from twisted/384-cli-help
Use text from debian man pages for CLI help output.
2 parents f7ab085 + c839a36 commit 07baa2b

File tree

6 files changed

+116
-14
lines changed

6 files changed

+116
-14
lines changed

src/towncrier/_settings/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77
ConfigError = load.ConfigError
88
load_config_from_options = load.load_config_from_options
99

10+
# Help message for --config CLI option, shared by all sub-commands.
11+
config_option_help = (
12+
"Pass a custom config file at FILE_PATH. "
13+
"Default: towncrier.toml or pyproject.toml file, "
14+
"if both files exist, the first will take precedence."
15+
)
1016

1117
__all__ = [
18+
"config_option_help",
1219
"load_config",
1320
"ConfigError",
1421
"load_config_from_options",

src/towncrier/_shell.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# See LICENSE for details.
33

44
"""
5-
towncrier, a builder for your news files.
5+
Entry point of the command line interface.
6+
7+
Each sub-command has its separate CLI definition andd help messages.
68
"""
79

810
import click
@@ -18,6 +20,22 @@
1820
@click.group(cls=DefaultGroup, default="build", default_if_no_args=True)
1921
@click.version_option(__version__.public())
2022
def cli():
23+
"""
24+
Towncrier is a utility to produce useful, summarised news files for your project.
25+
Rather than reading the Git history as some newer tools to produce it, or having
26+
one single file which developers all write to, towncrier reads "news fragments"
27+
which contain information useful to end users.
28+
29+
Towncrier delivers the news which is convenient to those that hear it, not those
30+
that write it.
31+
32+
That is, a “news fragment” (a small file containing just enough information to
33+
be useful to end users) can be written that summarises what has changed from the
34+
“developer log” (which may contain complex information about the original issue,
35+
how it was fixed, who authored the fix, and who reviewed the fix). By compiling
36+
a collection of these fragments, towncrier can produce a digest of the changes
37+
which is valuable to those who may wish to use the software.
38+
"""
2139
pass
2240

2341

src/towncrier/build.py

+32-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
from ._builder import find_fragments, render_fragments, split_fragments
1717
from ._git import remove_files, stage_newsfile
1818
from ._project import get_project_name, get_version
19-
from ._settings import ConfigError, load_config_from_options
19+
from ._settings import (
20+
ConfigError,
21+
config_option_help,
22+
load_config_from_options,
23+
)
2024
from ._writer import append_to_newsfile
2125

2226

@@ -30,11 +34,31 @@ def _get_date():
3034
"draft",
3135
default=False,
3236
flag_value=True,
33-
help="Render the news fragments, don't write to files, don't check versions.",
37+
help=(
38+
"Render the news fragments to standard output. "
39+
"Don't write to files, don't check versions."
40+
),
41+
)
42+
@click.option(
43+
"--config",
44+
"config_file",
45+
default=None,
46+
metavar="FILE_PATH",
47+
help=config_option_help,
48+
)
49+
@click.option(
50+
"--dir",
51+
"directory",
52+
default=None,
53+
metavar="PATH",
54+
help="Build fragment in directory. Default to current directory.",
55+
)
56+
@click.option(
57+
"--name",
58+
"project_name",
59+
default=None,
60+
help="Pass a custom project name.",
3461
)
35-
@click.option("--config", "config_file", default=None, help="Configuration file name.")
36-
@click.option("--dir", "directory", default=None)
37-
@click.option("--name", "project_name", default=None)
3862
@click.option(
3963
"--version",
4064
"project_version",
@@ -58,6 +82,9 @@ def _main(
5882
project_date,
5983
answer_yes,
6084
):
85+
"""
86+
Build a combined news file from news fragment.
87+
"""
6188
try:
6289
return __main(
6390
draft,

src/towncrier/check.py

+28-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import click
1111

1212
from ._builder import find_fragments
13-
from ._settings import load_config_from_options
13+
from ._settings import config_option_help, load_config_from_options
1414

1515

1616
def _run(args, **kwargs):
@@ -19,10 +19,34 @@ def _run(args, **kwargs):
1919

2020

2121
@click.command(name="check")
22-
@click.option("--compare-with", default="origin/master")
23-
@click.option("--dir", "directory", default=None)
24-
@click.option("--config", "config", default=None)
22+
@click.option(
23+
"--compare-with",
24+
default="origin/master",
25+
metavar="BRANCH",
26+
help=(
27+
"Checks files changed running git diff --name-ony BRANCH... "
28+
"BRANCH is the branch to be compared with. "
29+
"Default to origin/master"
30+
),
31+
)
32+
@click.option(
33+
"--dir",
34+
"directory",
35+
default=None,
36+
metavar="PATH",
37+
help="Check fragment in directory. Default to current directory.",
38+
)
39+
@click.option(
40+
"--config",
41+
"config",
42+
default=None,
43+
metavar="FILE_PATH",
44+
help=config_option_help,
45+
)
2546
def _main(compare_with, directory, config):
47+
"""
48+
Check for new fragments on a branch.
49+
"""
2650
return __main(compare_with, directory, config)
2751

2852

src/towncrier/create.py

+29-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,29 @@
55
Create a new fragment.
66
"""
77

8-
98
import os
109

1110
import click
1211

13-
from ._settings import load_config_from_options
12+
from ._settings import config_option_help, load_config_from_options
1413

1514

1615
@click.command(name="create")
1716
@click.pass_context
18-
@click.option("--dir", "directory", default=None)
19-
@click.option("--config", "config", default=None)
17+
@click.option(
18+
"--dir",
19+
"directory",
20+
default=None,
21+
metavar="PATH",
22+
help="Create fragment in directory. Default to current directory.",
23+
)
24+
@click.option(
25+
"--config",
26+
"config",
27+
default=None,
28+
metavar="FILE_PATH",
29+
help=config_option_help,
30+
)
2031
@click.option(
2132
"--edit/--no-edit",
2233
default=False,
@@ -31,6 +42,20 @@
3142
)
3243
@click.argument("filename")
3344
def _main(ctx, directory, config, filename, edit, content):
45+
"""
46+
Create a new news fragment.
47+
48+
Create a new news fragment called FILENAME or pass the full path for a file.
49+
Towncrier has a few standard types of news fragments, signified by the file extension.
50+
51+
\b
52+
These are:
53+
* .feature - a new feature
54+
* .bugfix - a bug fix
55+
* .doc - a documentation improvement,
56+
* .removal - a deprecation or removal of public API,
57+
* .misc - a ticket has been closed, but it is not of interest to users.
58+
"""
3459
return __main(ctx, directory, config, filename, edit, content)
3560

3661

src/towncrier/newsfragments/384.doc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The CLI help messages were updated to contain more information.

0 commit comments

Comments
 (0)