Sah/Schema/filename/default_only_file_in_curdir.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 10 / 10 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« Sah/Schema/filename/default_newest_file_in_curdir.pm ↑ Summary Sah/Schema/filename/default_only_file_not_dir_in_curdir.pm »
1 package Sah::Schema::filename::default_only_file_in_curdir;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6 1 our $DATE = '2024-02-16'; # DATE
7 1 our $DIST = 'Sah-SchemaBundle-Path'; # DIST
8 1 our $VERSION = '0.031'; # VERSION
9  
10 1 our $schema = ["filename" => {
11 summary => 'File name, defaults to only file in current directory (if there is one)',
12 description => <<'MARKDOWN',
13  
14 This is like the `filename` schema but with a default value of "only file in the
15 current directory". That is, if the current directory has a single plain file
16 and nothing else.
17  
18 Difference with `filename::default_only_file_not_subdir_in_subdir` schema: the
19 other schema ignores subdirectories. Thus, if a directory only contains `file1`
20 and `subdir1`, then that other schema will return `file1` but this schema will
21 not return a default value.
22  
23 Note: be careful when using this schema for actions that are destructive,
24 because a user can perform those actions without giving an argument (e.g. in a
25 `delete-file` script). It is safer to use this schema when performing a
26 non-destructive action (e.g. `checksum`) and/or operate in dry-run mode by
27 default.
28  
29 MARKDOWN
30 'x.perl.default_value_rules' => ['Path::only_file_in_curdir'],
31 }];
32  
33 1 1;
34 # ABSTRACT: File name, defaults to only file in current directory (if there is one)
35  
36 __END__
« Sah/Schema/filename/default_newest_file_in_curdir.pm ↑ Summary Sah/Schema/filename/default_only_file_not_dir_in_curdir.pm »