NAME

PiFlash::State - PiFlash::State class to store configuration, device info and program state

VERSION

version 0.4.0

SYNOPSIS

# initialize: creates empty sub-objects and accessor functions as shown below
PiFlash::State->init("system", "input", "output", "cli_opt", "log");

# better initialization - use PiFlash's state category list function
my @categories = PiFlash::state_categories();
PiFlash::State->init(@categories);

# core functions
$bool_verbose_mode = PiFlash::State::verbose()
$bool_logging_mode = PiFlash::State::logging()
PiFlash::State::odump
PiFlash::State->error("error message");

# system accessors
my $system = PiFlash::State::system();
my $bool = PiFlash::State::has_system($key);
my $value = PiFlash::State::system($key);
PiFlash::State::system($key, $value);

# input accessors
my $input = PiFlash::State::input();
my $bool = PiFlash::State::has_input($key);
my $value = PiFlash::State::input($key);
PiFlash::State::input($key, $value);

# output accessors
my $output = PiFlash::State::output();
my $bool = PiFlash::State::has_output($key);
my $value = PiFlash::State::output($key);
PiFlash::State::output($key, $value);

# cli_opt accessors
my $cli_opt = PiFlash::State::cli_opt();
my $bool = PiFlash::State::has_cli_opt($key);
my $value = PiFlash::State::cli_opt($key);
PiFlash::State::cli_opt($key, $value);

# log accessors
my $log = PiFlash::State::log();
my $bool = PiFlash::State::has_log($key);
my $value = PiFlash::State::log($key);
PiFlash::State::log($key, $value);

DESCRIPTION

This class contains internal functions used by PiFlash to store command-line parameters, input & output file data, available device data and program logs.

PiFlash uses the device info to refuse to write/destroy a device which is not an SD card. This provides a safeguard while using root permissions against a potential error which has happened where users have accidentally erased the wrong block device, losing a hard drive they wanted to keep.

SEE ALSO

piflash, PiFlash::Command, PiFlash::Inspector

AUTHOR

Ian Kluft <cpan-dev@iankluft.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017-2019 by Ian Kluft.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004