diff options
author | Stephen Finucane <stephen@that.guru> | 2021-12-08 17:09:27 +0000 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2022-02-20 12:04:07 -0800 |
commit | 39ee8b0580ee48c43801feaa0c9a5b454a3e0e19 (patch) | |
tree | 9e84c8330d8d2e2230d3bfeffd3592937ba7cd31 /tests | |
parent | 4262661a0fffabe3803f1bd876b19244f587dafa (diff) | |
download | click-39ee8b0580ee48c43801feaa0c9a5b454a3e0e19.tar.gz |
Store raw help string for commands
Some tools, such as sphinx-click [1], may wish to access the full help
string for a command including any text after the form feed character
(which indicates truncation [2]). Make this possible by storing the
help string without truncation and instead truncate when we use this
string (i.e. truncate on load, not on store).
[1] https://github.com/click-contrib/sphinx-click/issues/56
[2] https://click.palletsprojects.com/en/latest/documentation/#truncating-help-texts
Signed-off-by: Stephen Finucane <stephen@that.guru>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_commands.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index fa2773d..bf6a5db 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -95,6 +95,20 @@ def test_auto_shorthelp(runner): ) +def test_help_truncation(runner): + @click.command() + def cli(): + """This is a command with truncated help. + \f + + This text should be truncated. + """ + + result = runner.invoke(cli, ["--help"]) + assert result.exit_code == 0 + assert "This is a command with truncated help." in result.output + + def test_no_args_is_help(runner): @click.command(no_args_is_help=True) def cli(): |