Commit ecccd718 authored by Chris Lamb's avatar Chris Lamb 💬

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

parent f784d2cd
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment