azuma, kuniyuki > Haineko-0.2.16 > Haineko::CLI

Download:
Haineko-0.2.16.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Haineko::CLI - Base class for command line interface

DESCRIPTION ^

Haineko::CLI is a base class for command line interface of Haineko.

SYNOPSIS ^

    use Haineko::CLI;
    my $p = { 'pidfile' => '/tmp/haineko.pid' };
    my $c = Haineko::CLI::Daemon->new( %$p );

    $c->parseoptions;   # Parse command-line options
    $c->makepf;         # Make a pid file
    $c->readpf;         # Return the process id of running process
    $c->removepf;       # Remove the pid file

CLASS METHODS ^

new( %arguments )

new() is a constructor of Haineko::CLI::Daemon

    my $e = Haineko::CLI::Daemon->new(
            'verbose' => 2,         # Verbose level
            'logging' => {          # Syslog configuration
                'disabled' => 0,
                'facility' => 'local2',
            },
            'pidfile' => '/tmp/pid',# process id file
    );

version

version() returns the version number of Haineko.

which( command-name )

which() has the same feature of UNIX-command ``which''.

stdin

stdin() returns the result of -t STDIN.

stdout

stdout() returns the result of -t STDOUT.

stderr

stderr() returns the result of -t STDERR.

INSTANCE METHODS ^

r( run-mode )

r() returns current "run mode" value, and r(2) set "run mode" to ``2''

v( verbose-level )

v() returns current verbose level value, and v(2) set "verbose level" to ``2''

e( Error message, Continue )

e() prints error message to STDERR and exit. if the second argument is given, such as e('message', 1), running process does not exit.

p( message, verbose level )

p() prints message to STDERR. if the second argument is given, for example, p('message',2), given message will be printed when the value of verbose level is 2 or higher.

makepf()

makepf() creates pid file at the value of pidfile property of the instance. If the value of pidfile is not defined or is empty, pid file is not created.

readpf()

readpf() returns the process id of running process read from the value of pidfile property of running process.

removepf()

removepf() delete the pid file.

SEE ALSO ^

REPOSITORY ^

https://github.com/azumakuniyuki/Haineko

AUTHOR ^

azumakuniyuki <perl.org [at] azumakuniyuki.org>

LICENSE ^

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

syntax highlighting: