API(3)

πŸ“¦
version 3.15 Β· 2 versions
, in fedora 43

πŸ’– API(3) β€” QWizard::API πŸ’–

bestie you have FOUND the page ✨ this one lives in User Contributed Perl Documentation and it's literally called API(3). buckle up, it's short, it's sweet, and it will save you from hand-writing a million hashes. 🫢


🌸 NAME 🌸

QWizard::API β€” Generate questions using an API. πŸ’…


✨ SYNOPSIS ✨

okay so here's the whole vibe in one little code block, no notes:

  use QWizard::API;

  my $primaries =
  (
   qw_primary('aprim', 'My title', 'An introduction',
              [ qw_text('textresult', 'Enter something'),
                qw_checkbox('checkresult', 'display results?', 1, 0)]);
   # ...
  );

see? clean, short, iconic. 😌


πŸ¦‹ DESCRIPTION πŸ¦‹

So QWizard::API is a wrapper around generating questions for use inside a QWizard question set. πŸ’–

Functionally? The only reason you'd do this is to use an API instead of hand-encoding your HASH and ARRAY structures. That's it. That's the whole plot. πŸ“–

And the payoff is that the result might be slightly less verbose β€” because you can just leave the tags off. Like, name => 'something' becomes literally just 'something'. so much typing saved, so much wrist preserved. πŸ™


πŸ‘‘ API πŸ‘‘

big important thing first, no cap: all of the APIs mentioned here take additional arguments at the end, and those can be other hash pairs passed to the created objects beyond the defaults that the APIs create. so like. you can always sneak extra stuff in at the end. πŸ’«

🌟 Primary creation

To create a primary:

qw_primary(name, title, introduction, [questions], [post_answers], [actions])

that's your whole question set's main character energy right there. πŸŽ€

🌈 Widget creation

πŸ’¬ Text entry:

qw_text(name, question text);
qw_textbox(name, question text);

βœ… Checkboxes:

qw_checkbox(name, question text, optional:onval, optional:offval);

(and yes, onval and offval are optional β€” they're marked optional: for a reason, bestie πŸ“)

qw_menu(name, question text, [values] | {labels});
qw_radio(name, question text, [values] | {labels});

note the [values] | {labels} situation β€” array or hash, you pick, choose your own adventure. πŸ¦‹

🏷️ Labels:

qw_label(lefttext, righttext);
qw_paragraph(lefttext, rightparagraph);

πŸ™ˆ Hidden vars:

qw_hidden(name, value);

πŸ”˜ Buttons:

qw_button(name, question text, clicked value, button label);

πŸ’€ TODO πŸ’€

  • OO interface.

that's it. that's the whole todo list. someone get on it fr fr 😭


🎁 EXPORT 🎁

here's what you get handed on a little platter:

  qw_primary
  qw_text
  qw_textbox
  qw_checkbox
  qw_radio
  qw_menu

🧚 AUTHOR 🧚

Wes Hardaker <hardaker@tislabs.com> β€” thank you for your service, legend. πŸ«‘πŸ’œ


πŸ”₯ SEE ALSO πŸ”₯


friendly reminder that all those APIs above take extra arguments at the end for passing more hash pairs into the objects they create β€” don't forget your bonus settings! ✨

and that's the tea β˜• β€” this page is from perl v5.42.0, dated 2025-07-25, and it's API(3) in the User Contributed Perl Documentation. slay, go build some questions, you got this πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from