App::Sp...Tutorial(3)
hey bestie π this is App::Sp...Tutorial(3) β the User Contributed Perl Documentation page for App::Spec::Tutorial. Itβs literally the tutorial for how to write an app with App::Spec::Run. Main character energy for your CLI, no cap. β¨
πΈ NAME πΈ
App::Spec::Tutorial β how to write an app with App::Spec::Run. Thatβs the whole name, bestie, and it ate. π
π LINKS π
π Options and parameters π
See App::Spec::Argument for the documentation and examples on how to define options and parameters. Go peek, iykyk. π«Ά
π οΈ GENERATOR π οΈ
You can generate a boilerplate with appspec:
appspec new --class App::Birthdays --name birthdays.pl
For documentation, look at appspec and App::AppSpec. Theyβre the ones with the lore. πβ¨
π EXAMPLES π
π A minimal app called birthdays.pl π
The smallest example would be the following app. It doesnβt use subcommands β literally zero subcommands, none, nada. π
π§ birthdays.pl π§
use strict;
use warnings;
package App::Birthdays;
use base 'App::Spec::Run::Cmd';
sub execute {
my ($self, $run) = @_;
my $date = $run->options->{date};
my $output = <<"EOM";
Birthdays $date:
EOM
$output .= "Larry Wall";
if ($run->options->{age}) {
$output .= " (Age: unknown)";
}
$output .= "\n";
$run->out($output);
}
package main;
use App::Spec;
App::Spec->read("$Bin/birthdays.yaml")->runner->run;
π birthdays.yaml π
Short version:
name: birthdays.pl
title: Show birthdays
appspec: { version: '0.001' }
class: App::Birthdays
options:
- date=s =today --Date
- age --Show age
Long version:
name: birthdays.pl
title: Show birthdays
appspec: { version: '0.001' }
class: App::Birthdays
options:
- name: date
type: string
default: today
summary: Date
- name: age
type: flag
summary: Show age
And thatβs the whole page, bestie β perl v5.42.0, dated 2025-03-26, from App::Sp...Tutorial(3). Slay your CLI era πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-App-Spec 0.15.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms