NAME

Pb::Command::Context - context object for a Pb command

VERSION

This document describes version 0.01_01 of Pb::Command::Context.

DESCRIPTION

This is the command context class used by Pb. A lot of it is for internal use, but some methods may be useful for calling on the $FLOW object.

ATTRIBUTES

runmode

Whether commands are printed or not then executed or not.

statfile

Status file for the command (if any).

proc_pidfile

Proc::Pidfile object for the command (if any).

toplevel_command

CLI::Osprey object for the (ultimate) parent of the current command. (If the command has no parent, toplevel_command is just the current command.)

update_statfile

Whether or not to update the "statfile" for the current error.

error

Last recorded error.

logfile

Logfile for the command (if any).

pidfile

File containing the PID (if any).

METHODS

set_debug

Set debugging to a certain level.

set_var

Set a context variable to a certain value.

raise_error

Register a generic error.

syntax_error

Register a syntax error (e.g. during parsing).

usage_error

Register a usage error (e.g. caused by a bad argument).

start_conditions_not_met

Register a error which indicates that the command cannot run because the environment is not in an expected state.

setup_context

Establish the context. If called as a class method, this is a constructor; if called as an object method, it creates a copy of the given context and then builds up from there. You pass in initial context variables, option definitions, and a control structure.

connect_to

Connect a context to an Osprey command. This always has to be done eventually, but generally you have to wail until runtime, when we know which command the user chose.

validate_args

Loop through arguments (passed in) and validate that they all pass type constraints (also passed in). As a side effect, set each argument as a context var.

validate_opts

Loop through options (already present in the context) and validate that they all pass type constraints (passed in).

prep_logfile

Get a logfile ready for outputting to.

prep_pidfile

Build a Proc::Pidfile object and handle any "already running" issues.

AUTHOR

Buddy Burden <barefootcoder@gmail.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2020 by Buddy Burden.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)