App-optex

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    domingo, 22 de octubre de 2017, 18:00:00 JST

When the specified module was not found in library path, **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
`~/.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 `__DATA__`.  Using this, you can prepare
multiple set of options for different purposes.  Think about generic
**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 `~/.optex.d/optex.rc` like:

    autoload -Mi18n --cn --tw --us --fr --de --it --jp --kr --br --es --ru

lib/App/optex/util.pm  view on Meta::CPAN


use strict;
use warnings;

use List::Util qw(pairmap);

=pod

=over 7

=item B<setenv>(I<NAME>=VALUE,I<NAME2>=VALUE2,...)

Set environment variable I<NAME> to I<VALUE>, and so on.

=back

=cut

sub setenv {
    pairmap { $ENV{$a} = $b } @_;
}

=pod

=over 7

=item B<chdir>(B<PATH>=I<directory>)

Change working directory to I<directory>.

script/optex  view on Meta::CPAN

    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

script/optex  view on Meta::CPAN

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 0.867 second using v1.01-cache-2.11-cpan-3989ada0592 )