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::Options
  • MooX::Cmd
  • MooX::ConfigFromFile
  • MooX::Log::Any

πŸ‘‘ AUTHOR πŸ‘‘

celogeek <me@celogeek.com> β€” author icon energy πŸ‘‘

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