Skip to content
Snippets Groups Projects
Commit ecccd718 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Truncate very long command lines when displaying them as an external source of data.

parent f784d2cd
No related branches found
No related tags found
No related merge requests found
......@@ -280,7 +280,7 @@ class Difference:
if 'source' not in kwargs:
source_cmd = command1 or command2
kwargs['source'] = source_cmd.shell_cmdline()
kwargs['source'] = source_cmd.shell_cmdline(truncate=120)
try:
difference = Difference.from_feeder(
......
......@@ -18,7 +18,7 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
def format_cmdline(cmd, replace=()):
def format_cmdline(cmd, replace=(), truncate=None):
def fn(x):
if x in replace:
return '{}'
......@@ -27,4 +27,9 @@ def format_cmdline(cmd, replace=()):
x = x[1:-1]
return x
return ' '.join(fn(x) for x in cmd)
result = ' '.join(fn(x) for x in cmd)
if truncate is not None and len(result) > truncate:
result = result[: truncate + 4] + " […]"
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment