MooX::O...MooXCmd(3)
okay bestie, buckle up π the header calls this MooX::O...MooXCmd(3), but the full glow-up is MooX::Options::Manual::MooXCmd(3) β a User Contributed Perl Documentation moment about managing your tools with MooX::Cmd. No cap, it's giving command-line main character energy.
β¨ NAME β¨
MooX::Options::Manual::MooXCmd β manage your tools with MooX::Cmd. Periodt.
π¦ SYNOPSIS π¦
Here's the whole vibe in code, bestie β keep it exactly as written, characters matter more than vibes inside a code block π«Ά
package MyTool;
use strict; use warnings all => "FATAL";
use Class::Load qw(load_class);
use DBIx::LogAny;
use Moo;
use MooX::Cmd => with_config_from_file; # enable MooX::Cmd driven _build_config_prefixes
use MooX::Options => with_config_from_file; # enable --config-files and --config-prefix
with "MooX::Log::Any";
option option log_adapter => (is => "ro", required => 1, trigger => 1, json => 1 );
option connection => (is => "ro", required => 1, json => 1);
sub _trigger_log_adapter { my ( $self, $opts ) = @_; load_class("Log::Any::Adapter")->set( @{$opts} ); }
sub execute {
my $self = shift;
my $conn = $self->connection;
$conn->[3] ||= {};
$conn->[3]->{dbix_la_logger} = $self->log;
my $dbh = DBIx::LogAny->connect( @{$conn} );
...
}
π DESCRIPTION π
MooX::Cmd gives you an easy way to organize your tools into many subcommands. That's literally the whole point, and it ate.
We can take git as a example β iconic behavior, honestly:
git checkout [params]
git commit [params]
MooX::ConfigFromFile gives you a more easy way to configure recurring or complex parameters. Yes bestie, recurring and complex β the config fairy is real π§. MooX::ConfigFromFile finds and loads several configuration files based on your setup. Please read MooX::ConfigFromFile::Role carefully to learn which files from which location are loaded and how this can be tuned.
MooX::Options plays natively with these tools, and they play natively with MooX::Options. Mutual slay, no notes.
$ cat bin/mytool
#!/opt/myprj/bin/perl
use strict; use warnings all => "FATAL";
use MyTool;
MyTool->new_with_cmd->execute
MooX::Options improves the help message to display automatically the subcommands. It's giving helpful, honestly π₯
π SEE ALSO π
Go check these besties out:
MooX::OptionsMooX::CmdMooX::ConfigFromFileMooX::Log::Any
π AUTHOR π
celogeek <me@celogeek.com> β author icon energy π
π COPYRIGHT AND LICENSE π
Copyright tea, spill it carefully:
This software is copyright (c) 2013 by celogeek <me@celogeek.com>.
This software is copyright (c) 2017 by Jens Rehsack.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
kisses and command-line sparkles π
this page comes from perl v5.42.0, dated 2019-04-03. Byeeee π¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-MooX-Options 4.103-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms