#!/usr/bin/env perl

use strict;
use warnings;

our $VERSION = "1.04";

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
    -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

=head1 VERSION

Version 1.04

=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<--unexpand>, B<-u>

Behave as unexpand command.

=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>.

=back

=head1 INCOMPATIBILITY

There is no C<-a> option for C<ansiunexpand> and it always convert all
spaces not only leading ones.  Use normal L<unexpand(1)> to convert
just leading spaces.

C<ansiexpand -u> or C<ansiunexpand> convert all spaces whenever possible
including single space even if it does not reduce total data length.

=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-2023 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
