MooseX:...::Simple(3)
πΈ NAME πΈ
Hey bestie! The page header says MooseX:...::Simple(3) and it's from the User Contributed Perl Documentation β and the module is MooseX::App::Simple: Single command applications. One command, no command-hunting chaos, that's the vibe. β¨
β¨ SYNOPSIS β¨
Okay so here's the whole setup, bestie β code stays exactly as it is, no cap:
package MyApp;
use MooseX::App::Simple qw(Config Color);
parameter 'param' => (
is => 'rw',
isa => 'Str',
documentation => q[First parameter],
required => 1,
); # Positional parameter
option 'my_option' => (
is => 'rw',
isa => 'Bool',
documentation => q[Enable this to do fancy stuff],
); # Option (--my_option)
has 'private' => (
is => 'rw',
); # not exposed
sub run {
my ($self) = @_;
# Do something
}
And then in some simple wrapper script:
#!/usr/bin/env perl
use MyApp;
MyApp->new_with_options->run;
π DESCRIPTION π
MooseX::App::Simple works basically just as MooseX::App, however it does not search for commands and assumes that you have all options and parameters defined in the current class. It's giving "one class, one command, zero mystery" energy. π
Read the Tutorial for getting started with a simple MooseX::App command line application. That's the actual recommendation, bestie β go read the Tutorial. π
π«Ά METHODS π«Ά
π new_with_options π
my $myapp_command = MyApp->new_with_options();
This method reads the command line arguments from the user and tries to create instantiate the current class with the ARGV-input. If it fails it returns a MooseX::App::Message::Envelope object holding an error message. π
You can pass a hash or hashref of default params to new_with_options:
MyApp->new_with_options( %default );
Optionally you can pass a custom ARGV to this constructor:
my $obj = MyApp->new_with_options( ARGV => \@myARGV );
However, if you do so you must take care of propper @ARGV encoding yourself. Yes, that part is on you, bestie. π«Ά
π OPTIONS π
Same as in MooseX::App, however all options regarding command loading such as app_namespace and app_exclude are not available here. So don't go looking for them β they ghosted this module. π»
π§ PLUGINS π§
Same as in MooseX::App. However plugings adding additional commands (eg. version) will have no effect with MooseX::App::Simple. So if you were expecting extra commands to appear, no cap: they won't. π
π₯ SEE ALSO π₯
- Read the Tutorial for getting started with a simple
MooseX::Appcommand line application. π - See
MooseX::GetoptandMooX::Optionsfor alternatives. π
xoxo, your Unix bestie π
β this page is MooseX:...::Simple(3), and the footer vibes say source/version perl v5.42.0, date 2024-08-09. Bye bestie, go slay those single-command apps! π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-MooseX-App 1.430.1-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