summaryrefslogtreecommitdiff
path: root/docs/api/utils.rst
blob: 0fc11b5004890a2bb0c2ec3b27fe4e52472e0308 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
cmd2.utils
==========


Settings
--------

.. autoclass:: cmd2.utils.Settable
    :members:

    .. automethod:: __init__


Quote Handling
--------------

.. autofunction:: cmd2.utils.is_quoted

.. autofunction:: cmd2.utils.quote_string

.. autofunction:: cmd2.utils.quote_string_if_needed

.. autofunction:: cmd2.utils.strip_quotes

.. autofunction:: cmd2.utils.quote_specific_tokens

.. autofunction:: cmd2.utils.unquote_specific_tokens


IO Handling
-----------

.. autoclass:: cmd2.utils.StdSim
    :members:

.. autoclass:: cmd2.utils.ByteBuf
    :members:

.. autoclass:: cmd2.utils.ProcReader
    :members:


Tab Completion
--------------

.. autoclass:: cmd2.utils.CompletionMode

    .. attribute:: NONE

        Tab completion will be disabled during read_input() call. Use of custom
        up-arrow history supported.

    .. attribute:: COMMANDS

        read_input() will tab complete cmd2 commands and their arguments.
        cmd2's command line history will be used for up arrow if history is not
        provided. Otherwise use of custom up-arrow history supported.

    .. attribute:: CUSTOM

        read_input() will tab complete based on one of its following parameters
        (choices, choices_provider, completer, parser). Use of custom up-arrow
        history supported

.. autoclass:: cmd2.utils.CustomCompletionSettings

    .. automethod:: __init__


Text Alignment
--------------

.. autoclass:: cmd2.utils.TextAlignment
    :members:
    :undoc-members:

.. autofunction:: cmd2.utils.align_text

.. autofunction:: cmd2.utils.align_left

.. autofunction:: cmd2.utils.align_right

.. autofunction:: cmd2.utils.align_center

.. autofunction:: cmd2.utils.truncate_line


Miscellaneous
-------------

.. autofunction:: cmd2.utils.to_bool

.. autofunction:: cmd2.utils.categorize

.. autofunction:: cmd2.utils.remove_duplicates

.. autofunction:: cmd2.utils.alphabetical_sort

.. autofunction:: cmd2.utils.natural_sort