MooseX:...in::Term(3)

πŸ’… MooseX::App::Plugin::Term(3) β€” like, the whole vibe

okay so bestie, welcome to the MooseX::App::Plugin::Term page from the User Contributed Perl Documentation πŸŽ€ β€” yes that's the manual name, and yes it's a whole thing, but the actual tea is this plugin lets your app literally ask the person at the keyboard for the stuff they forgot to type. iconic behaviour, honestly.


✨ NAME ✨

MooseX::App::Plugin::Term β€” the plugin that lets you specify options/parameters via terminal prompts 🫢


🌸 SYNOPSIS 🌸

In your base class, you do this little number:

package MyApp;
use MooseX::App qw(Term);

Then in your command class:

package MyApp::SomeCommand;
use MooseX::App::Command;

option 'some_option' => (
    is             => 'rw',
    isa            => 'Int',
    documentation  => 'Something',
    cmd_term       => 1,
);

sub run {
    my ($self) = @_;
    say "Some option is ".$self->some_option;
}

And then in your shell, the moment of truth πŸ”₯:

bash$ myapp some_command
Something (Required, an integer):
test
Value must be an integer (not 'test')
1

Some option is 1

like?? it asked, it validated, it slayed. periodt πŸ’…


πŸ’– DESCRIPTION πŸ’–

So here's the lore: this plugin can prompt the user for any missing options/parameters right there on the terminal. πŸ¦‹

But β€” and this is the key part, bestie β€” the user only gets prompted if:

  • the parameter wasn't already provided by different means (that's a parameter and option, or config files and environment values if the respective plugins have been loaded before this plugin), and
  • the script is actually connected to an interactive terminal.

no interactive terminal? no vibes, no prompt. it just doesn't happen. πŸ™ˆ

Also, lowkey the best part: term input has basic editing capabilities β€” cursor, del, backspace and history. it's giving "little readline that could" ✨


fr fr though: keep the loading order in mind. the config-file and environment plugins have to come before this one for their values to count as "already provided", so the prompt doesn't come for something you already answered. iykyk 🌈

🌟 SEE ALSO 🌟

no SEE ALSO section here, bestie β€” the original page doesn't have one, so we're not inventing one. πŸ’€


that's the whole manual! πŸ’œ cute little sign-off: this page was rendered as part of perl v5.42.0, dated 2024-08-09 β€” go off, perl. πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from