#!/usr/bin/env perl

use strict;
use warnings;

our $VERSION = "1.06";

BEGIN {
    if ($0 =~ /unexpand$/) {
	$App::ansiexpand::DEFAULT_UNEXPAND = 1;
    }
}

use  App::ansiexpand;
exit App::ansiexpand->new->run(splice @ARGV);

__END__

=encoding utf-8

=head1 NAME

ansiexpand, ansiunexpand - ANSI sequences aware tab expand/unexpand command

=head1 SYNOPSIS

ansiexpand [ option ] file ...

ansiunexpand [ option ] file ...

    -u --unexpand               convert spaces to tabs
    -x --minimum=[#]            minimum space count to be converted
    -t --tabstop=#              tab stop width
       --tabhead=char           tab head character
       --tabspace=char          tab space character
       --tabstyle=style         tab style
       --ambiguous=wide|narrow  width of Unicode ambiguous character
    -z --zap                    read whole contents at once

=head1 VERSION

Version 1.06

=head1 DESCRIPTION

B<ansiexpand> is an L<expand(1)> compatible command utilizing
L<Text::ANSI::Tabs> module, which enables to handle ANSI terminal
sequences and Unicode wide characters.  Not only expanding tabs to
spaces, it can visualize them in various styles.

This is a command line interface for L<Text::ANSI::Tabs> module, which
uses L<Text::ANSI::Fold> module as a backend.  Consult them for
implementation detail.

=head1 OPTIONS

=over 7

=item B<-u>, B<--unexpand>

Behave as unexpand command.

=item B<-a>

This option exists only for compatibility with the C<unexpand>
command.  It can be used but has no effect on the behavior of the
command.

=item B<-x>[#], B<--minimum>=[#]

By default, two or more consecutive whitespace characters are
converted by the B<-u> option or C<ansiunexpand> command.  This option
sets the minimum number of whitespace characters to be converted.  If
no value is given, a value of 1 is assumed, and all possible
whitespace is converted to tabs.

=item B<--tabstop>=#, B<-t>#

Set tab stop width.  Unlike L<expand(1)>, takes only single value.

=item B<--tabhead>=I<char>

=item B<--tabspace>=I<char>

Set tab head and following space character.  If longer than single
character, it is considered as a Unicode name.

=item B<--tabstyle>, B<--ts>

=item B<--tabstyle>=I<style>, B<--ts>=...

=item B<--tabstyle>=I<head-style>,I<space-style> B<--ts>=...

Set the style how tab is expanded.  Select C<symbol> or C<shade> for
example.  If two style names are combined, like
C<squat-arrow,middle-dot>, use C<squat-arrow> for tabhead and
C<middle-dot> for tabspace.

Show available style list if called without parameter.  Styles are
defined in L<Text::ANSI::Fold> library.

=item B<--ambiguous>=C<wide>|C<narrow>

Set the width of Unicode ambiguous characters.  Default is C<narrow>.

=item B<-z>, B<--zap>

Instead of processing one line at a time, read all data contained in
the file at once and processed together.

=back

=head1 INCOMPATIBILITY

C<ansiunexpand>, with or without the C<-a> option, always converts all
possible spaces, not just leading ones.  Because there is no point in
using the C<ansiunexpand> command to convert only leading spaces, so
please use the normal L<unexpand(1)> in that case.

=head1 FILES

=over 4

=item F<~/.ansiunexpandrc>

=item F<~/.ansiexpandrc>

Start-up file.
See L<Getopt::EX::Module> for format.

=back

=head1 INSTALL

=head2 CPANMINUS

    $ cpanm App::ansiexpand

=head1 SEE ALSO

L<App::ansiexpand>, L<https://github.com/tecolicom/App-ansiexpand>

L<Text::ANSI::Tabs|https://github.com/tecolicom/Text-ANSI-Tabs>

L<Text::ANSI::Fold|https://github.com/tecolicom/Text-ANSI-Fold>

=head1 AUTHOR

Kazumasa Utashiro

=head1 LICENSE

Copyright ©︎ 2021-2024 Kazumasa Utashiro

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

=cut

#  LocalWords:  perl unexpand utf ansiexpand ansiunexpand tabstop
#  LocalWords:  tabhead tabspace tabstyle Unicode ansiexpandrc cpanm
#  LocalWords:  ansiunexpandrc CPANMINUS Kazumasa Utashiro
