NAME

Developer::Dashboard::Handle - in-process proxy for the dashboard/d2 CLI

VERSION 4.30

PURPOSE

Gives Perl code a single-line way to reach the same runtime the dashboard/d2 command line resolves, instead of hand-building a Developer::Dashboard::PathRegistry, Developer::Dashboard::FileRegistry, and Developer::Dashboard::Config to answer one question such as a configured path alias.

WHY IT EXISTS

Filed after the project's owner asked directly (over the project's Telegram bridge) for a shorter Perl equivalent of dashboard path resolve NAME, then widened the request to cover any dashboard subcommand: "Anything I can run with d2 on bash [...] I am expecting the d2() subroutine can do the same." paths() answers the original, narrower ask in-process (no subprocess, since path aliases are cheap to resolve directly against the registry); run() and AUTOLOAD answer the widened one by shelling out to the real CLI for everything else, which is the only way to reach the full command surface without reimplementing it.

WHEN TO USE

From any Perl script or module in this project (or one with this distribution installed) that needs a configured path alias, or the output of any other dashboard subcommand, without forking a subprocess by hand and parsing its output itself.

HOW TO USE

use Developer::Dashboard;

my $foo = d2->paths->{foo};              # fast, in-process

# A bareword method starts a LAZY chain. Nothing runs until the chain is
# terminated with a call - the trailing ->().
my $out = d2->doctor->();                # shells to `dashboard doctor`
my $lst = d2->collector->list->();       # shells to `dashboard collector.list`

# Un-terminated, a chain is inert and says so if you print it:
print d2->collector->list;               # "d2 proxy: collector.list"

my $res = d2->run( 'tira.ticket.show', '--ref', 'DD-726' );
                                         # run() still takes its words separately

d2() (exported by Developer::Dashboard) memoizes one handle per working directory, so repeated calls from the same directory reuse the same registry rather than rebuilding it.

WHAT USES IT

Nothing in the shipped CLI itself - this is a convenience entrypoint for external Perl code (scripts, other distributions) that embeds this one. Developer::Dashboard::CLI::Paths and the rest of the CLI continue to build their own registries directly, unchanged by this module.

EXAMPLES

use Developer::Dashboard;

# A custom alias added with `dashboard path add reports /var/reports`:
my $dir = d2->paths->{reports};   # '/var/reports'

# UNDERSCORES BECOME HYPHENS in every segment, because a Perl method name
# cannot contain a hyphen and hyphenated commands are the shell's normal
# spelling. Without the rewrite that half of the CLI is unreachable here.
my $out = d2->foo->bar->soemthing_executable->();  # `dashboard foo.bar.soemthing-executable`

# The cost of that rewrite: a command genuinely spelled with an underscore
# cannot be named through the chain. Use run() for those - it is verbatim.
my $verbatim = d2->run('an_underscored_command');

# Anything else the CLI can do - remember the terminating ->():
my $version_text = d2->version->();

# Arbitrary depth, mirroring the CLI's own dotted dispatch:
my $out = d2->foo->bar->zzz->();  # `dashboard foo.bar.zzz`