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: ...@@ -280,7 +280,7 @@ class Difference:
if 'source' not in kwargs: if 'source' not in kwargs:
source_cmd = command1 or command2 source_cmd = command1 or command2
kwargs['source'] = source_cmd.shell_cmdline() kwargs['source'] = source_cmd.shell_cmdline(truncate=120)
try: try:
difference = Difference.from_feeder( difference = Difference.from_feeder(
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>. # 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): def fn(x):
if x in replace: if x in replace:
return '{}' return '{}'
...@@ -27,4 +27,9 @@ def format_cmdline(cmd, replace=()): ...@@ -27,4 +27,9 @@ def format_cmdline(cmd, replace=()):
x = x[1:-1] x = x[1:-1]
return x 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