Added a -C/--center option to string pad.

The --center option does exactly what you'd expect. When a
perfectly centred result is not possible, this adds extra padding to
the left. If the --right option is also given, the extra padding is
added to the right.
This commit is contained in:
Isaac Oscar Gariano
2025-08-28 13:18:45 +10:00
parent c0c9245d99
commit 6149ac4e40
13 changed files with 88 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ Synopsis
.. synopsis::
string pad [-r | --right] [(-c | --char) CHAR] [(-w | --width) INTEGER]
string pad [-r | --right] [-C | --center] [(-c | --char) CHAR] [(-w | --width) INTEGER]
[STRING ...]
.. END SYNOPSIS
@@ -22,6 +22,8 @@ Description
The escape sequences reflect what fish knows about, and how it computes its output. Your terminal might support more escapes, or not support escape sequences that fish knows about.
If **-C** or **--center** is given, add the padding to before and after the string. If it is impossible to perfectly center the result (because the required amount of padding is an odd number), extra padding will be added to the left, unless **--right** is also given.
If **-r** or **--right** is given, add the padding after a string.
If **-c** or **--char** is given, pad with *CHAR* instead of whitespace.

View File

@@ -18,7 +18,7 @@ Synopsis
[-g | --groups-only] [-r | --regex] [-n | --index]
[-q | --quiet] [-v | --invert]
PATTERN [STRING ...]
string pad [-r | --right] [(-c | --char) CHAR] [(-w | --width) INTEGER]
string pad [-r | --right] [-C | --center] [(-c | --char) CHAR] [(-w | --width) INTEGER]
[STRING ...]
string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [-N | --no-newline]
[-q | --quiet] [STRING ...]