Skip to content

Commit

Permalink
update document
Browse files Browse the repository at this point in the history
  • Loading branch information
kaz-utashiro committed Sep 1, 2024
1 parent 76214f9 commit f201644
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ follows.

use Text::ANSI::Printf 'ansi_printf';
use Term::ANSIColor::Concise 'ansi_color';
ansi_printf("| %-5s | %-5s | %-5s |\n",
ansi_printf("| %-8s | %-8s | %-8s |\n",
ansi_color("R", "Red", "GI", "Green", "BIU", "Blue"));

Using the command line interface, `ansiprintf`, and the companion
command, `ansiecho`, the shell command can be executed as follows.

ansiprintf "| %-5s | %-5s | %-5s |\n" $(ansiecho -cR Red -cGI Green -cBIU Blue)
ansiprintf "| %-8s | %-8s | %-8s |\n" $(ansiecho -cR Red -cGI Green -cBIU Blue)

In fact, this can be done with the `ansiecho` command alone.

ansiecho -f "| %-5s | %-5s | %-5s |" -cR Red -cGI Green -cBIU Blue
ansiecho -f "| %-8s | %-8s | %-8s |" -cR Red -cGI Green -cBIU Blue

# ARGUMENT REORDERING

Expand Down
8 changes: 4 additions & 4 deletions lib/Text/ANSI/Printf.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ this code produces the output like:
=begin :text
| Red | Green | Blue |
| Red | Green | Blue |
=end :text
Expand Down Expand Up @@ -159,17 +159,17 @@ follows.
use Text::ANSI::Printf 'ansi_printf';
use Term::ANSIColor::Concise 'ansi_color';
ansi_printf("| %-5s | %-5s | %-5s |\n",
ansi_printf("| %-8s | %-8s | %-8s |\n",
ansi_color("R", "Red", "GI", "Green", "BIU", "Blue"));
Using the command line interface, C<ansiprintf>, and the companion
command, C<ansiecho>, the shell command can be executed as follows.
ansiprintf "| %-5s | %-5s | %-5s |\n" $(ansiecho -cR Red -cGI Green -cBIU Blue)
ansiprintf "| %-8s | %-8s | %-8s |\n" $(ansiecho -cR Red -cGI Green -cBIU Blue)
In fact, this can be done with the C<ansiecho> command alone.
ansiecho -f "| %-5s | %-5s | %-5s |" -cR Red -cGI Green -cBIU Blue
ansiecho -f "| %-8s | %-8s | %-8s |" -cR Red -cGI Green -cBIU Blue
=head1 ARGUMENT REORDERING
Expand Down
31 changes: 24 additions & 7 deletions script/ansiprintf
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,43 @@ screen.

For example, next command

printf '|%-5s|%-5s|%-5s|\n' Red Green Blue
printf '| %-8s | %-8s | %-8s |\n' Red Green Blue

will print

|Red |Green|Blue |
=begin :text

| Red | Green | Blue |

=end :text

=begin html

<p><img width="300" src="https://raw.githubusercontent.com/tecolicom/Text-ANSI-Printf/master/images/plain.png">

=end html

and

ansiprintf '|%-5s|%-5s|%-5s|\n' \
$'\e[31mRed\e[m' $'\e[32mGreen\e[m' $'\e[34mBlue\e[m'
COLORS=($'\e[31mRed\e[m' $'\e[32;3mGreen\e[m' $'\e[34;3;4mBlue\e[m')
ansiprintf '| %-8s | %-8s | %-5s |\n' ${COLORS[@]}

will produce same result with colored arguments.

=begin html

<p><img width="300" src="https://raw.githubusercontent.com/tecolicom/Text-ANSI-Printf/master/images/good.png">

=end html

You can give colored arguments with L<ansiecho(1)> command:

ansiprintf '|%-5s|%-5s|%-5s|\n' $(ansiecho -cR Red -cG Green -cB Blue)
COLORS=($(ansiecho -cR Red -cGI Green -cBIU Blue))
ansiprintf "| %-8s | %-8s | %-8s |\n" ${COLORS[@]}

but this can be done with just L<ansiecho(1)>:

ansiecho -f '|%-5s|%-5s|%-5s|' -cR Red -cG Green -cB Blue
ansiecho -f "| %-8s | %-8s | %-8s |" -cR Red -cGI Green -cBIU Blue

In addition to handling ANSI terminal sequences, L<ansisprintf> has
the following features.
Expand Down Expand Up @@ -97,7 +114,7 @@ Kazumasa Utashiro

=head1 LICENSE

Copyright © 2023- Kazumasa Utashiro.
Copyright © 2023-2024 Kazumasa Utashiro.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Expand Down

0 comments on commit f201644

Please sign in to comment.