App-SahUtils
view release on metacpan or search on metacpan
script/coerce-with-sah view on Meta::CPAN
=back
=head1 COMPLETION
This script has shell tab completion capability with support for several
shells.
=head2 bash
To activate bash completion for this script, put:
complete -C coerce-with-sah coerce-with-sah
in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.
It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.
=head2 tcsh
To activate tcsh completion for this script, put:
complete coerce-with-sah 'p/*/`coerce-with-sah`/'
in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.
It is also recommended to install L<shcompgen> (see above).
=head2 other shells
For fish and zsh, install L<shcompgen> as described above.
=head1 FAQ
=head2 When there is an error (e.g. in generating coercer code, in coercing) the program returns undef/null, how do I see the error message?
Pass `--no-naked-res` to see the error code and error message. The default is
naked for simpler output.
=head1 CONFIGURATION FILE
This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.
By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F</home/u1/.config/coerce-with-sah.conf>, F</home/u1/coerce-with-sah.conf>, or F</etc/coerce-with-sah.conf>.
All found files will be read and merged.
To disable searching for configuration files, pass C<--no-config>.
You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.
You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...
You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...
To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:
[plugin=DumpArgs]
-event=before_validate_args
-prio=99
[plugin=Foo]
-event=after_validate_args
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
coerce_rules (see --coerce-rule)
coerce_to (see --coerce-to)
compiler (see --compiler)
data_as_json (see --data-as-json)
data_as_perl (see --data-as-perl)
data_with_result (see --data-with-result)
format (see --format)
linenum (see --linenum)
multiple_data_as_json (see --multiple-data-as-json)
multiple_data_as_perl (see --multiple-data-as-perl)
naked_res (see --naked-res)
return_type (see --return-type)
show_code (see --show-code)
show_rules (see --show-rules)
type (see --type)
=head1 ENVIRONMENT
=head2 COERCE_WITH_SAH_OPT
String. Specify additional command-line options.
=head1 FILES
=head2 /home/u1/.config/coerce-with-sah.conf
=head2 /home/u1/coerce-with-sah.conf
=head2 /etc/coerce-with-sah.conf
=head1 EXAMPLES
=head2 Example #1
% coerce-with-sah date --coerce-to DateTime --data-as-perl '"2016-05-22"'
do {
my $a = bless({
formatter => undef,
local_c => {
day => 22,
day_of_quarter => 52,
day_of_week => 7,
day_of_year => 143,
hour => 0,
minute => 0,
month => 5,
quarter => 2,
second => 0,
year => 2016,
},
local_rd_days => 736106,
local_rd_secs => 0,
locale => bless({
am_pm_abbreviated => ["AM", "PM"],
available_formats => {
"Bh" => "h B",
"Bhm" => "h:mm B",
( run in 0.847 second using v1.01-cache-2.11-cpan-39bf76dae61 )