IO::Prompt::Tiny(3pm)

πŸ“¦
version 0.003 Β· 6 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– IO::Prompt::Tiny β€” bestie edition πŸ’–

okay so this page is IO::Prompt::Tiny(3pm) from the User Contributed Perl Documentation, and honestly? it's the little module that could. tiny name, tiny job, zero drama. let's get into it 🫢


✨ NAME ✨

IO::Prompt::Tiny β€” prompt ur user for input, but with a default option so nobody's left hanging πŸ’…


🌸 VERSION 🌸

version 0.003 β€” she's small, she's stable, she's iconic


πŸŽ€ SYNOPSIS πŸŽ€

use IO::Prompt::Tiny qw/prompt/;

my $answer = prompt("Yes or no? (y/n)", "n");

that's it. that's the whole vibe. import prompt, call prompt, get an answer. periodt ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so this is an extremely simple prompting module. like, extremely extremely. it's based on the extremely simple prompt that ExtUtils::MakeMaker offers, and here's the tea: in sooo many cases, that's literally all you need. this module hands it to you without dragging in all the overhead of ExtUtils::MakeMaker just to ask one lil question. not me avoiding an entire build system for a y/n prompt 😭 iconic behavior fr fr

it does not do validation. no coloring. no menus. no timeouts. none of the wild, crazy, cool stuff other prompting modules get up to. it just prompts with a default. that's it! πŸ’€


πŸ’œ USAGE πŸ’œ

the following function may be explicitly imported. no functions are imported by default β€” so yes bestie, you gotta ask for it by name πŸŽ€

prompt

my $value = prompt($message);
my $value = prompt($message, $default);

the prompt() function displays the message as a prompt for input, then returns the (chomped) response from the user β€” or the default, if the response came back empty. no trailing newline nonsense, she chomps. πŸ’…

if the program is not running interactively, or if the PERL_MM_USE_DEFAULT environment variable is set to true, the default gets used without prompting at all. so in CI, nobody's sitting there staring at a cursor like πŸ‘οΈπŸ‘„πŸ‘οΈ

if no default is provided, an empty string is used instead. simple as that.

and here's a lil glow-up moment: unlike ExtUtils::MakeMaker::prompt(), this prompt() does not use prototypes, so this works as expected:

my @args = ($prompt, $default);
prompt(@args);

no prototype jumpscare. we love to see it πŸ”₯


🌈 ENVIRONMENT 🌈

PERL_MM_USE_DEFAULT

if this is set to a true value, IO::Prompt::Tiny will always return the default without waiting for user input β€” just like ExtUtils::MakeMaker does. set it and forget it, bestie 😌


🌟 ACKNOWLEDGMENTS 🌟

the guts of this module are based on ExtUtils::MakeMaker and IO::Interactive::Tiny (which is itself based on IO::Interactive). thank you to the authors of those modules β€” they really carried the squad here 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

  • IO::Prompt
  • IO::Prompt::Simple
  • Prompt::Timeout
  • Term::Prompt

all the cousins at the family reunion πŸ’–


🧚 SUPPORT 🧚

Bugs / Feature Requests

please report any bugs or feature requests through the issue tracker at <https://github.com/dagolden/IO-Prompt-Tiny/issues>. you will be notified automatically of any progress on your issue β€” so you're never left on read, fr fr πŸ’¬

Source Code

this is open source software. the code repository is available for public review and contribution under the terms of the license.

<https://github.com/dagolden/IO-Prompt-Tiny>

git clone https://github.com/dagolden/IO-Prompt-Tiny.git

go clone her, she's waiting πŸ¦‹


⭐ AUTHOR ⭐

David Golden <dagolden@cpan.org> β€” king behavior, no cap πŸ‘‘


this software is Copyright (c) 2012 by David Golden.

this is free software, licensed under:

The Apache License, Version 2.0, January 2004

lowkey a whole legal situation but make it slay. respect the license bestie, it's the rules πŸ’…

πŸŽ€ sign-off πŸŽ€

and that's the whole page!! she's perl v5.36.0, dated 2022-10-13, and lives her life as IO::Prompt::Tiny(3pm) in the User Contributed Perl Documentation. go prompt somebody. with a default. as a treat. πŸ’–βœ¨πŸŒΈπŸ¦‹πŸŽ€

πŸ“¦ where this page comes from