NAME

App::LDAP::Role::Command - make a class act as a command

SYNOPSIS

package App::LDAP::Command::YourCommand;
use Moose;
with 'App::LDAP::Role::Command';

has foo => (
    is  => "rw",
    isa => "Str",
);

around prepare => sub {
    my $orig = shift;
    my $self = shift;

    # hook some actions

    $self->$orig(@_);
};

sub run {
    my $self = shift;
    # do something
}

package main;
App::LDAP::Command::YourCommand->new_with_options()->prepare()->new();

DESCRIPTION

This role should be included in any module aimed at being a handler in App::LDAP. It mixs the MooseX::Getopt and App::LDAP::Role and defines the wrappers to Namespace::Dispatch. That is, a command can declare the acceptable options as describing in MooseX::Getopt, invoking helpers from App::LDAP::Role, and dispatching like 'use Namespace::Dispatch'.

METHODS

prepare()

the instance method invoked before running.

$class->new_with_options()->prepare()->run()

this method is designed to be hooked with 'around' in Moose and just returns the instance itself here.

dispatch()

the wrapper of Namespace::Dispatch::dispatch()

$class->dispatch(@consequences)

has_leaf()

the wrapper of Namespace::Dispatch::has_leaf()

$class->has_leaf('name');

leaves

the wrapper of Namespace::Dispatch::leaves()

$submodules = $class->leaves();

encrypt($plain)

given a plain text password, the helper returns an encrypted one.

$hashed = encrypt($plain);

new_password()

read and confirm the new password from terminal. die if failing to confirm.

$plain = new_password();