Skip to content

Commit 103122b

Browse files
committed
Fix table wrapping bug
1 parent aaaeee1 commit 103122b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

keep/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,20 @@ def first_time_use(ctx):
6565

6666
def list_commands(ctx):
6767
table_data = [['Command', 'Description', 'Alias']]
68-
commands = read_commands()
68+
no_of_columns = len(table_data[0])
6969

70+
commands = read_commands()
7071
for cmd, fields in commands.items():
7172
table_data.append(['$ ' + cmd, fields['desc'], fields['alias']])
7273

7374
table = AsciiTable(table_data)
74-
max_widths = [table.column_max_width(0), table.column_max_width(1)]
75+
max_width = table.table_width//3
7576

7677
for i in range(len(table_data) - 1):
77-
for j in [0, 1]:
78+
for j in range(no_of_columns):
7879
data = table.table_data[i + 1][j]
79-
if len(data) > max_widths[j]:
80-
table.table_data[i + 1][j] = '\n'.join(wrap(data, max_widths[j]))
80+
if len(data) > max_width:
81+
table.table_data[i + 1][j] = '\n'.join(wrap(data, max_width))
8182

8283
table.inner_row_border = True
8384
print(table.table)

0 commit comments

Comments
 (0)