App::C...Prompt(3pm)
π App::Cmd::Plugin::Prompt π
okay bestie, welcome to App::Cmd::Plugin::Prompt β the manual page, but make it cute. this is the lil plugin that lets you plug prompting routines straight into your App::Cmd commands. you get to ask your users stuff and they have to answer. it's giving interactive. it's giving main character energy. β¨
πΈ VERSION πΈ
version 1.006 β no cap, that's the one.
π SYNOPSIS π
so here's the vibe. in your app, you set it up like this:
package MyApp;
use App::Cmd::Setup -app => {
plugins => [ qw(Prompt) ],
};
and then in your command, you actually use it:
package MyApp::Command::dostuff;
use MyApp -command;
sub run {
my ($self, $opt, $args) = @_;
return unless prompt_yn('really do stuff?', { default => 1 });
...
}
like, imagine just asking "really do stuff?" and bailing if they say no. iconic behavior honestly. π
π¦ PERL VERSION π¦
this library should run on perls released even a long time ago. it should work on any version of perl released in the last five years. she's flexible, she's adaptable, she's lowkey timeless.
although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. the version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
translation bestie: don't come at her asking her to support your ancient perl. she said what she said. π
β¨ SUBROUTINES β¨
π prompt_str
my $input = prompt_str($prompt, \%opt)
this one prompts a user for string input. it can be directed to persist until input is 'acceptable'. so if they type nonsense, she will simply ask again until they get it right. persistent queen. π
valid options are:
inputβ optional coderef, which, when invoked, returns the user's response; default is to read fromSTDIN.outputβ optional coderef, which, when invoked (with two arguments: the prompt and the choices/default), should prompt the user; default is to write toSTDOUT.validβ an optional coderef which any input is passed into and which must return true in order for the program to continuedefaultβ may be any string; must pass the'valid'coderef (if given)choicesβ what to display after the prompt; default is either the'default'parameter or nothingno_valid_defaultβ do not test the'default'parameter against the'valid'coderefinvalid_default_errorβ error message to throw when the'default'parameter is not valid (does not pass the'valid'coderef)
π prompt_yn
my $bool = prompt_yn($prompt, \%opt);
this prompts the user for a yes or no response and won't give up until it gets one. she is nothing if not determined. it returns true for yes and false for no.
valid options are:
defaultβ may be yes or no, indicating how to interpret an empty response; if empty, require an explicit answer; defaults to empty
ngl, if you leave it empty, there's no vibing your way out of answering. they must pick. π€
π prompt_any_key($prompt)
my $input = prompt_any_key($prompt);
this routine prompts the user to "press any key to continue." $prompt, if supplied, is the text to prompt with. classic move. the "any key" moment. we've all been there. π«Ά
π SEE ALSO π
App::Cmdβ the whole reason she exists, go say hi
π« AUTHOR π«
Ricardo Signes <cpan@semiotic.systems>
β CONTRIBUTOR β
Ricardo Signes <rjbs@semiotic.systems>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2004 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie!! πβ¨ this was App::Cmd::Plugin::Prompt version 1.006, from the User Contributed Perl Documentation, dated 2023-01-24, running under perl v5.36.0. go prompt somebody. slay. π
π¦ where this page comes from
- debian bookworm: libapp-cmd-plugin-prompt-perl 1.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libapp-cmd-plugin-prompt-perl 1.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libapp-cmd-plugin-prompt-perl 1.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libapp-cmd-plugin-prompt-perl 1.006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms