App-optex
view release on metacpan or search on metacpan
script/optex view on Meta::CPAN
expand no_pdf ! -iname *.pdf
option --clean \
repository -prune -o \
-type f \
no_dots \
no_version no_backup \
no_image \
no_archive \
no_pdf
% find . --clean -print
=head2 MODULES
B<optex> also supports module extension. In the example of C<date>,
module file is found at F<~/.optex.d/date/> directory. If default
module, F<~/.optex.d/date/default.pm> exists, it is loaded
automatically on every execution.
This is a normal Perl module, so package declaration and the final
true value is necessary. Between them, you can put any kind of Perl
code. For example, next program set environment variable C<LANG> to
C<C> before executing C<date> command.
package default;
$ENV{LANG} = 'C';
1;
% /bin/date
2017å¹´ 10æ22æ¥ æ¥ææ¥ 18æ00å00ç§ JST
% date
Sun Oct 22 18:00:00 JST 2017
Other modules are loaded using C<-M> option. Unlike other options,
C<-M> have to be placed at the beginning of argument list. Module
files in F<~/.optex.d/date/> directory are used only for C<date>
command. If the module is placed on F<~/.optex.d/> directory, it can
be used from all commands.
If you want use C<-Mes> module, make a file F<~/.optex.d/es.pm> with
following content.
package es;
$ENV{LANG} = 'es_ES';
1;
% date -Mes
domingo, 22 de octubre de 2017, 18:00:00 JST
When the specified module was not found in library path, B<optex>
ignores the option and stops argument processing immediately. Ignored
options are passed through to the target command.
Module is also used with subroutine call. Suppose
F<~/.optex.d/env.pm> module look like:
package env;
sub setenv {
while (($a, $b) = splice @_, 0, 2) {
$ENV{$a} = $b;
}
}
1;
Then it can be used in more generic fashion. In the next example,
first format is easy to read, but second one is more easy to type
because it does not have special characters to be escaped.
% date -Menv::setenv(LANG=de_DE) # need shell quote
% date -Menv::setenv=LANG=de_DE # alternative format
So 22 Okt 2017 18:00:00 JST
Option aliases can be also declared in the module, at the end of file,
following special literal C<__DATA__>. Using this, you can prepare
multiple set of options for different purposes. Think about generic
B<i18n> module:
package i18n;
1;
__DATA__
option --cn -Menv::setenv(LANG=zh_CN) // ä¸å½èª - ç°¡ä½å
option --tw -Menv::setenv(LANG=zh_TW) // ä¸å½èª - ç¹ä½å
option --us -Menv::setenv(LANG=en_US) // è±èª
option --fr -Menv::setenv(LANG=fr_FR) // ãã©ã³ã¹èª
option --de -Menv::setenv(LANG=de_DE) // ãã¤ãèª
option --it -Menv::setenv(LANG=it_IT) // ã¤ã¿ãªã¢èª
option --jp -Menv::setenv(LANG=ja_JP) // æ¥æ¬èª
option --kr -Menv::setenv(LANG=ko_KR) // éå½èª
option --br -Menv::setenv(LANG=pt_BR) // ãã«ãã¬ã«èª - ãã©ã¸ã«
option --es -Menv::setenv(LANG=es_ES) // ã¹ãã¤ã³èª
option --ru -Menv::setenv(LANG=ru_RU) // ãã·ã¢èª
This can be used like:
% date -Mi18n --tw
2017å¹´10æ22æ¥ é±æ¥ 18æ00å00ç§ JST
You can declare autoload module in your F<~/.optex.d/optex.rc> like:
autoload -Mi18n --cn --tw --us --fr --de --it --jp --kr --br --es --ru
Then you can use them without module option. In this case, option
C<--ru> is replaced by C<-Mi18n --ru> automatically.
% date --ru
воÑкÑеÑенÑе, 22 окÑÑбÑÑ 2017 г. 18:00:00 (JST)
Module C<i18n> is implemented as L<Getopt::EX::i18n> and included in
this distribution. So it can be used as above without additional
installation.
=head1 STANDARD MODULES
Standard modules are installed at C<App::optex>, and they can be
addressed with and without C<App::optex> prefix.
=over 4
=item -MB<help>
Print available option list. Option name is printed with substitution
form, or help message if defined. Use B<-x> option to omit help
message.
Option B<--man> or B<-h> will print document if available. Option
B<-l> will print module path. Option B<-m> will show the module
itself. When used after other modules, print information about the
last declared module. Next command show the document about B<second>
module.
optex -Mfirst -Msecond -Mhelp --man
=item -MB<debug>
Print debug messages.
=item -MB<util::argv>
Module to manipulate command argument.
See L<App::optex::util::argv> for detail.
=item -MB<util::filter>
Module to implement command input/output filters.
See L<App::optex::util::filter> for detail.
=back
=head1 Getopt::EX MODULES
In addition to its own modules, B<optex> can also use C<Getopt::EX>
script/optex view on Meta::CPAN
=back
=head1 ENVIRONMENT
=over 4
=item OPTEX_ROOT
Override default root directory F<~/.optex.d>.
=item OPTEX_CONFIG
Override default configuration file F<OPTEX_ROOT/config.toml>.
=item OPTEX_MODULE_PATH
Set module paths separated by colon (C<:>). These are inserted before
standard path.
=item OPTEX_BINDIR
Override default symbolic link directory F<OPTEX_ROOT/bin>.
=back
=head1 SEE ALSO
L<Getopt::EX>, L<Getopt::EX::Loader>, L<Getopt::EX::Module>
L<App::optex::textconv>
L<App::optex::xform>
=head1 AUTHOR
Kazumasa Utashiro
=head1 LICENSE
You can redistribute it and/or modify it under the same terms
as Perl itself.
=head1 COPYRIGHT
The following copyright notice applies to all the files provided in
this distribution, including binary files, unless explicitly noted
otherwise.
Copyright 2017-2024 Kazumasa Utashiro
=cut
# LocalWords: optex rc iso greple awk pdf LANG ENV Oct JST domingo
# LocalWords: setenv autoload PERLLIB BINDIR Utashiro Kazumasa
( run in 1.143 second using v1.01-cache-2.11-cpan-5837b0d9d2c )