App::Sp...Argument(3)
π NAME π
Hey bestie! This is the App::Spec::Argument(3) page from the User Contributed Perl Documentation, and it is literally about App::Spec objects representing command line options or parameters. No cap. π
β¨ SYNOPSIS β¨
(The original leaves this section empty β no synopsis lines to copy, bestie. Just vibes.)
πΈ EXAMPLES πΈ
Okay so options can be defined in a verbose way via key value pairs, but you can also use a shorter syntax. Both? Obsessed. π«Ά
The idea comes from Ingy's http://www.schematype.org/.
The first item of the string is the name of the option using a syntax very similar to the one from Getopt::Long.
Then you can optionally define a type, a default value and a summary. Cute.
You can see a list of supported syntax in this example from t/data/12.dsl.yaml:
---
# version with short dsl syntax
name: myapp
appspec: { version: 0.001 }
class: App::Spec::Example::MyApp
title: My Very Cool App
options:
- spec: foo --Foo
- spec: verbose|v+ --be verbose
- spec: +req --Some required flag
- spec: number=i --integer option
- spec: number2|n= +integer --integer option
- spec: fnumber=f --float option
- spec: fnumber2|f= +float --float option
- spec: date|d=s =today
- spec: items=s@ --multi option
- spec: set=s% --multiple key=value pairs
---
# version with verbose syntax
name: myapp
appspec: { version: 0.001 }
class: App::Spec::Example::MyApp
title: My Very Cool App
options:
- name: foo
type: flag
summary: Foo
- name: verbose
summary: be verbose
type: flag
multiple: true
aliases: ["v"]
- name: req
summary: Some required flag
required: true
type: flag
- name: number
summary: integer option
type: integer
- name: number2
summary: integer option
type: integer
aliases: ["n"]
- name: fnumber
summary: float option
type: float
- name: fnumber2
summary: float option
type: float
aliases: ["f"]
- name: date
type: string
default: today
aliases: ["d"]
- name: items
type: string
multiple: true
summary: multi option
- name: set
type: string
multiple: true
mapping: true
summary: multiple key=value pairs
π METHODS π
π common π
Builds a hash with the given hashref and fills in some defaults. Slay. β¨
my %hash = $class->common($args);
π¦ from_dsl π¦
Builds a hash from the dsl string. Periodt. π
%dsl = $class->from_dsl("verbose|v+ --Be verbose");
π name, type, multiple, required, unique, summary, description, default, completion, enum, values, mapping π
Attributes which represent the ones from the spec. π
That's the whole page, bestie! π«Ά This one is from perl v5.42.0 and dated 2025-03-26. Go slay those argument specs β¨π
π¦ 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