mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-28 07:31:14 -03:00
New command "string pad" to pad text to a given width (#7340)
Pads text to a given width, or the maximum width of all inputs.
This commit is contained in:
committed by
Johannes Altmanninger
parent
46746b4b26
commit
92511b09c4
50
doc_src/cmds/string-pad.rst
Normal file
50
doc_src/cmds/string-pad.rst
Normal file
@@ -0,0 +1,50 @@
|
||||
string-pad - pad characters before and after string
|
||||
===================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. BEGIN SYNOPSIS
|
||||
|
||||
::
|
||||
|
||||
string pad [(-r | --right)] [(-c | --char) CHAR] [(-w | --width) INTEGER] [STRING...]
|
||||
|
||||
.. END SYNOPSIS
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
.. BEGIN DESCRIPTION
|
||||
|
||||
``string pad`` pads each STRING with CHAR to the given width.
|
||||
|
||||
The default behavior is left padding with spaces and default width is the length of string (hence, no padding).
|
||||
|
||||
If ``-r`` or ``--right`` is given, only pad after string.
|
||||
|
||||
The ``-c`` or ``--char`` switch causes padding with the character CHAR instead of default whitespace character.
|
||||
|
||||
If ``-w`` or ``--width`` is given, pad the string to given width. Width less than the string width will result in an unchanged string.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. BEGIN EXAMPLES
|
||||
|
||||
::
|
||||
|
||||
>_ string pad -w 10 -c ' ' 'abc'
|
||||
abc
|
||||
|
||||
>_ string pad --right --width 12 --char=z foo barbaz
|
||||
foozzzzzzzzz
|
||||
barbazzzzzzz
|
||||
|
||||
>_ string pad -w 6 --char=- foo | string pad --right -w 9 --char=-
|
||||
---foo---
|
||||
|
||||
|
||||
.. END EXAMPLES
|
||||
@@ -15,6 +15,7 @@ Synopsis
|
||||
string length [(-q | --quiet)] [STRING...]
|
||||
string lower [(-q | --quiet)] [STRING...]
|
||||
string match [(-a | --all)] [(-e | --entire)] [(-i | --ignore-case)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...]
|
||||
string pad [(-r | --right)] [(-c | --char) CHAR] [(-w | --width) INTEGER] [STRING...]
|
||||
string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [(-N | --no-newline)] [(-q | --quiet)] [STRING...]
|
||||
string replace [(-a | --all)] [(-f | --filter)] [(-i | --ignore-case)] [(-r | --regex)] [(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
|
||||
string split [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] SEP [STRING...]
|
||||
@@ -141,6 +142,21 @@ Examples
|
||||
:start-after: BEGIN EXAMPLES
|
||||
:end-before: END EXAMPLES
|
||||
|
||||
"pad" subcommand
|
||||
------------------
|
||||
|
||||
.. include:: string-pad.rst
|
||||
:start-after: BEGIN SYNOPSIS
|
||||
:end-before: END SYNOPSIS
|
||||
|
||||
.. include:: string-pad.rst
|
||||
:start-after: BEGIN DESCRIPTION
|
||||
:end-before: END DESCRIPTION
|
||||
|
||||
.. include:: string-pad.rst
|
||||
:start-after: BEGIN EXAMPLES
|
||||
:end-before: END EXAMPLES
|
||||
|
||||
"repeat" subcommand
|
||||
-------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user