summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-12-09 15:11:13 +0100
committerJan Pokorný <jpokorny@redhat.com>2015-12-17 23:37:32 +0100
commita31036c5cee57d81da04a2d4f778b349918b9b40 (patch)
tree1d954db6af7e0a8e6c90ec6ac048d89d9567ccaa /commands
parent404a82a6585a9580de2812b57d3fbc2e41f908c8 (diff)
downloadclufter-a31036c5cee57d81da04a2d4f778b349918b9b40.tar.gz
clufter-a31036c5cee57d81da04a2d4f778b349918b9b40.tar.xz
clufter-a31036c5cee57d81da04a2d4f778b349918b9b40.zip
commands/cmd-wrap: expose eponymous filter on its own
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'commands')
-rw-r--r--commands/cmd_wrap.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/commands/cmd_wrap.py b/commands/cmd_wrap.py
new file mode 100644
index 0000000..49ca2af
--- /dev/null
+++ b/commands/cmd_wrap.py
@@ -0,0 +1,30 @@
+# -*- coding: UTF-8 -*-
+# Copyright 2015 Red Hat, Inc.
+# Part of clufter project
+# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
+"""cmd-wrap command"""
+__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
+
+from ..command import Command
+from ..protocol import protocols
+
+
+@Command.deco('cmd-wrap')
+def cmd_wrap(cmd_ctxt,
+ input="-",
+ output="-",
+ text_width='0'):
+ """Wrap long lines carrying (fairly) convoluted shell commands
+
+ Options:
+ input lines carrying moderately convoluted shell commands
+ output (hopefully) the same content fitting the text width
+ text_width for commands rewrapping (0/-1/neg. ~ auto/disable/hi-limit)
+ """
+ cmd_ctxt['text_width'] = text_width
+
+ file_proto = protocols.plugins['file'].ensure_proto
+ return (
+ file_proto(input),
+ file_proto(output),
+ )