NAME

App::FuguBench::Checkout - the checkout walk and the configuration reader

SYNOPSIS

use App::FuguBench::Checkout;
use Fugu::CLI ();

my $checkout = App::FuguBench::Checkout->new(start => $start)
    or return Fugu::CLI::EXIT_CONFIG_ERROR();

my ($dir, $home) = $checkout->config('wiki.dir');
$checkout->dir_value($dir) or die $checkout->error;

DESCRIPTION

App::FuguBench::Checkout finds the checkout of a verb, and reads the keys of .toolingrc there.

The walk has two stops. The first stop is the nearest directory with a .toolingrc, and that directory is the root. The second stop is the nearest .toolingrc on the walk that holds a key. The directory of that file is the home of the key.

A verb names the anchor of each relative value. A wiki. value anchors at the home of wiki.origin, and worktree.base anchors at the root. A clone under Projects/ holds its own .toolingrc without a wiki.origin key, so the home of wiki.origin is the workspace.

new

new(start => $dir) walks up from the start and records each directory that holds a .toolingrc, nearest first. The method returns undef when the walk reaches the filesystem root with none.

root

root returns the directory of the first .toolingrc on the walk.

config

config($key) returns the value of one key and its home, as a two-element list. The value comes from the nearest .toolingrc on the walk that holds the key, and the home is the directory of that file.

A key that no file on the walk holds takes its default, with the root as its home. These are the keys and their defaults:

wiki.dir

The directory of the library clone. The default is Wiki.

wiki.origin

The URL of the library repository. It has no default.

wiki.project

The project name of a session at the root. The default is the name of the root directory.

wiki.projects

The directory whose children are project clones. The default is Projects.

worktree.base

The directory of the worktrees. The default is .claude/worktrees.

A key with no default, and a key outside the table, give the empty list. A key outside the table belongs to another tool, and this module reads none of them.

A line of .toolingrc holds a key, whitespace, and a value. A line that starts with # is a comment.

dir_value

dir_value($value) is the shape check of a directory value. The value must be a relative path with no parent segment. The method returns the value, or undef with the reason in error.

url_value

url_value($value) is the shape check of a URL value. The value must hold a scheme and an authority, as https://example.org/x does. The method returns the value, or undef with the reason in error.

error

error returns the reason of the last failed shape check, or undef.

RETURN VALUES

new returns a checkout or undef. root returns a directory name. config returns a value and a home, or the empty list. dir_value and url_value return the value or undef. error returns a reason or undef.

SEE ALSO

App::FuguBench, Fugu::File

AUTHORS

Dick Olsson <hi@senzilla.io>