Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions invoke/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,12 +954,13 @@ def print_columns(
# Calculate column sizes: don't wrap flag specs, give what's left over
# to the descriptions.
name_width = max(len(x[0]) for x in tuples)
desc_width = (
desc_width = max(
1,
pty_size()[0]
- name_width
- self.leading_indent_width
- self.col_padding
- 1
- 1,
)
wrapper = textwrap.TextWrapper(width=desc_width)
for name, help_str in tuples:
Expand Down
15 changes: 15 additions & 0 deletions tests/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,21 @@ def docstrings_are_wrapped_to_terminal_width(self):
),
)

def long_task_names_may_exhaust_terminal_width(self):
name = (
"my-very-long-task-name-that-is-completely-legit-but-make-"
"grep-crash-aaaaaa"
)

def body(c):
pass # pragma: no cover

program = Program(namespace=Collection(Task(body, name=name)))
with patch("invoke.program.pty_size", return_value=(80, 24)):
stdout, _ = run("--list", program=program)

assert " {}\n".format(name) in stdout

def empty_collections_say_no_tasks(self):
expect(
"-c empty -l", err="No tasks found in collection 'empty'!\n"
Expand Down