summaryrefslogtreecommitdiffstats
path: root/commands/cmd_wrap.py
blob: 49ca2af1ca6dbd4d0e079b0f65420b6ba137f8ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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),
    )