NAME
App::Dispatcher - generate command-line dispatcher classes
SYNOPSIS
use App::Dispatcher qw/app_dispatcher/;
app_dispatcher( $class, $opt );
DESCRIPTION
This is the interface documentation for the App::Dispatcher class, which is generally not used directly by application authors. To make use of App::Dispatcher in your application you most likely want to be reading App::Dispatcher::Tutorial instead.
App::Dispatcher is a the implementation for the app-dispatcher(1) command. The implementation is contained in a single subroutine with that takes two mandatory arguments:
- app_dispatcher( $class, $opt )
-
- $class
-
The name space under which the command classes will be searched for.
- $opt
-
A Getopt::Long::Descriptive::Opts (or equivalent) object with the following methods:
- add_help
-
Add a '--help' option to every command.
- add_debug
-
Add a global '--debug-dispatcher' option. Useful for debugging the actual options your command classes are receiving. Automatically turns on 'add_mtime_check'.
- add_mtime_check
-
Warn at dispatch time if the command class file has a more recent modification date than the dispatch class.
- inc
-
Arrayref to add to @INC.
- path
-
Arrayref of directories to search for command classes.
- verbose
-
Print out extra details during execution.
- dry_run
-
Don't write out any files to disk.
- force
-
Force the overwriting of existing writeable files.
A successful run of app_dispatcher() results in the creation of 'lib/$class/Dispatcher.pm', which is based on the Command Classes found under 'lib/$class'.
The command classes may have the following methods defined:
- require_order
-
Optional. An boolean to set the Getopt::Long option 'require_order' when true, or set option 'permute' (the default) when false (or not defined).
- order
-
Optional. An integer to force the order in which commands are displayed.
- usage_desc
-
Optional. The string used for error messgaes. Will be auto-generated from the opt_spec and arg_spec methods if not implemented.
- opt_spec
-
Optional, but at least one of opt_spec or arg_spec should in most cases be implemented. A list of option definitions which will be passed to the describe_options method of Getopt::Long::Descriptive.
- arg_spec
-
Optional, but at least one of opt_spec or arg_spec should in most cases be implemented. A list of argument definitions which will be passed to the describe_options method of Getopt::Long::Descriptive.
- run
-
Optional, but it only makes sense to be left unimplemented if the command requires subcommands. This is the method where the real work is performed.
- abstract
-
Optional. A brief description of the command. Will be pulled from the POD documentation if not implemented.
App::Dispatcher is also its own Command Class. That is, it implements the opt_spec(), arg_spec() and run() methods.
SEE ALSO
app-dispatcher(1), App::Dispatcher::Tutorial(3p)
AUTHOR
Mark Lawrence <nomad@null.net>
COPYRIGHT AND LICENSE
Copyright (C) 2011 Mark Lawrence <nomad@null.net>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.