Andrew Sterling Hanenkamp > Form-Factory-0.020 > Form::Factory::Interface::CLI

Download:
Form-Factory-0.020.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.020   Source  

NAME ^

Form::Factory::Interface::CLI - Command-line interface builder for form factory

VERSION ^

version 0.020

SYNOPSIS ^

  #/usr/bin/perl
  use strict;
  use warnings;

  use Form::Factory;

  my $cli = Form::Factory->new_interface('CLI');
  my $action = $cli->new_action(shift @ARGV);
  
  $action->consume_and_clean_and_check_and_process;

  if ($action->is_valid and $action->is_success) {
      print "done.\n";
  }
  else {
      my $messages = $action->results->all_messages;
      print $messages;
      print "usage: $0 OPTIONS\n\n";
      print "Options:\n";
      $action->render;
  }

DESCRIPTION ^

Provides a simple interface for building command-line tools that manipulate actions.

ATTRIBUTES ^

renderer

This is a subroutine responsible for returning the usage parameters back to the user. The default prints to STDOUT.

get_args

This is a subroutine responsible for return a list of command-line arguments. The default implementation returns a reference to @ARGV.

get_file

This is a subroutine responsible for returning the contents of files used on the command-line. It is passed the interface object and then the name of the file to load. The default implementation slurps up the named file or, in the case of the name begin "-", returns the contents of STDIN.

METHODS ^

render_control

Prints a usage line for each control.

consume_control

Consumes the command-line arguments and files specified on the command-line to fill in the action.

AUTHOR ^

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright 2009 Qubling Software LLC.

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: