Sah/SchemaR/filename/exists/default_only_file_in_curdir.pm

filter: Statementstmt 100% 10 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 10 / 10 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« Sah/SchemaR/filename/exists.pm ↑ Summary Sah/SchemaR/filename/not_exists.pm »
1 ## no critic: TestingAndDebugging::RequireStrict
2 package Sah::SchemaR::filename::exists::default_only_file_in_curdir;
3  
4 1 our $DATE = '2024-02-16'; # DATE
5 1 our $VERSION = '0.031'; # VERSION
6  
7 1 our $rschema = do{my$var={base=>"filename::exists",clsets_after_base=>[{description=>"\nThis is like the `filename::exists` schema but with a default value of \"only\nfile in the current directory\". That is, if the current directory has a single\nplain file and nothing else.\n\nNote: be careful when using this schema for actions that are destructive,\nbecause a user can perform those actions without giving an argument (e.g. in a\n`delete-file` script). It is safer to use this schema when performing a\nnon-destructive action (e.g. `checksum`) and/or operate in dry-run mode by\ndefault.\n\n",summary=>"File name, must exist on the filesystem, defaults to only file in current directory (if there is one)","x.perl.default_value_rules"=>["Path::only_file_in_curdir"]}],clsets_after_type=>[{description=>"\nThis schema is basically string with some checks and prefilters. Why use this\nschema instead of plain ol' str? Mainly to give you the ability to change tilde\nto user's home directory, e.g. `~/foo.txt` into `/home/someuser/foo.txt`.\nNormally this expansion is done by a Unix shell, but sometimes your program\nreceives an unexpanded path, e.g. when you get it from some config file.\n\nSee also more OS-specific schemas like `filename::unix`, which adds some more\nchecks (e.g. filename cannot contain forward slash and each component cannot be\nlonger than 255 characters) and preprocessing (e.g. stripping extraneous slashes\nlike `foo//bar` into `foo/bar`.\n\nWhat's the difference between this schema and `dirname`? The default completion\nrule. `dirname`'s completion only includes directories and not files.\n\n",examples=>[{valid=>0,value=>""},{valid=>1,value=>"foo"},{valid=>1,value=>"foo/bar"}],min_len=>1,prefilters=>["Path::expand_tilde_when_on_unix","Path::strip_slashes_when_on_unix"],summary=>"Filesystem file name","x.completion"=>["filename"]},{description=>"\nThis is like the `filename` schema but with an extra check that the path must\nalready exist.\n\n",prefilters=>["Path::check_file_exists"],summary=>"File name, must exist on filesystem"},'$var->{clsets_after_base}[0]'],"clsets_after_type.alt.merge.merged"=>['$var->{clsets_after_type}[0]','$var->{clsets_after_type}[1]','$var->{clsets_after_base}[0]'],resolve_path=>["str","filename","filename::exists"],type=>"str",v=>2};$var->{clsets_after_type}[2]=$var->{clsets_after_base}[0];$var->{"clsets_after_type.alt.merge.merged"}[0]=$var->{clsets_after_type}[0];$var->{"clsets_after_type.alt.merge.merged"}[1]=$var->{clsets_after_type}[1];$var->{"clsets_after_type.alt.merge.merged"}[2]=$var->{clsets_after_base}[0];$var};
8  
9 1 1;
10 # ABSTRACT: File name, must exist on the filesystem, defaults to only file in current directory (if there is one)
11  
12 __END__
« Sah/SchemaR/filename/exists.pm ↑ Summary Sah/SchemaR/filename/not_exists.pm »