Ask::API - an API to ask users things
{ package Ask::AwesomeWidgets; use Moo; with 'Ask::API'; sub info { my ($self, %arguments) = @_; ... } sub entry { my ($self, %arguments) = @_; ... } }
Ask::API is a Moo role. This means that you can write your implementation as either a Moo or Moose class.
Ask::API
The only two methods that you absolutely must implement are info and entry.
info
entry
Ask::API provides default implementations of warning, error, question, file_selection, multiple_choice and single_choice methods, but they're not espcially good, so you probably want to implement most of those too.
warning
error
question
file_selection
multiple_choice
single_choice
If you name your package Ask::Something then Ask->detect will find it (via Module::Pluggable).
Ask::Something
Ask->detect
Methods used during detection are is_usable which is called as an object method, and should return a boolean indicating its usability (for example, if STDIN is not connected to a terminal, Ask::STDIO returns false), and quality which is called as a class method and should return a number between 0 and 100, 100 being a high-quality backend, 0 being low-quality.
is_usable
quality
Ask->detect returns the highest quality module that it can load, instantiate and claims to be usable.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Ask.
Ask.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2012-2013, 2020 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Ask, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ask
CPAN shell
perl -MCPAN -e shell install Ask
For more information on module installation, please visit the detailed CPAN module installation guide.