« Sah/Schema/perl/modname_with_optional_args.pm
↑ Summary
Sah/Schema/perl/distname/default_this_dist.pm »
| 1 | package Sah::Schema::perl::distname; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 7 | 1 | our $DATE = '2024-02-16'; # DATE | |
| 8 | 1 | our $DIST = 'Sah-SchemaBundle-Perl'; # DIST | |
| 9 | 1 | our $VERSION = '0.050'; # VERSION | |
| 10 | |||
| 11 | 1 | our $schema = [str => { | |
| 12 | summary => 'Perl distribution name, e.g. Foo-Bar', | ||
| 13 | match => '\A[A-Za-z_][A-Za-z_0-9]*(-[A-Za-z_0-9]+)*\z', | ||
| 14 | 'x.perl.coerce_rules' => [ | ||
| 15 | 'From_str::normalize_perl_distname', | ||
| 16 | ], | ||
| 17 | |||
| 18 | # provide a default completion which is from list of installed perl distributions | ||
| 19 | 'x.completion' => 'perl_distname', | ||
| 20 | |||
| 21 | description => <<'_', | ||
| 22 | |||
| 23 | This is a schema you can use when you want to accept a Perl distribution name, | ||
| 24 | e.g. `WWW-Mechanize`. It offers basic checking of syntax as well as a couple of | ||
| 25 | conveniences. First, it offers completion from list of locally installed Perl | ||
| 26 | distribution. Second, it contains coercion rule so you can also input | ||
| 27 | `Foo::Bar`, `Foo/Bar`, `Foo/Bar.pm`, or even 'Foo.Bar' and it will be normalized | ||
| 28 | into `Foo-Bar`. | ||
| 29 | |||
| 30 | To see this schema in action on the CLI, you can try e.g. the `dist-has-deb` | ||
| 31 | script from <pm:App::DistUtils> and activate its tab completion (see its manpage | ||
| 32 | for more details). Then on the CLI try typing: | ||
| 33 | |||
| 34 | % dist-has-deb WWW-<tab> | ||
| 35 | % dist-has-deb dzp/<tab> | ||
| 36 | |||
| 37 | Note that this schema does not check that the Perl disribution exists on CPAN or | ||
| 38 | is installed locally. To check that, use the `perl::distname::installed` schema. | ||
| 39 | And there's also a `perl::distname::not_installed` schema. | ||
| 40 | |||
| 41 | _ | ||
| 42 | }]; | ||
| 43 | |||
| 44 | 1 | 1; | |
| 45 | # ABSTRACT: Perl distribution name, e.g. Foo-Bar | ||
| 46 | |||
| 47 | __END__ | ||