« Sah/SchemaR/dirname/default_curdir_abs.pm
↑ Summary
Sah/SchemaR/dirname/default_only_subdir_not_file_in_curdir.pm »
| 1 | ## no critic: TestingAndDebugging::RequireStrict | ||
| 2 | package Sah::SchemaR::dirname::default_only_subdir_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=>"dirname",clsets_after_base=>[{description=>"\nThis is like the `dirname` schema but with a default value of \"only subdirectory\nin the current directory\". That is, if the current directory has a single\nsubdirectory and nothing else.\n\nDifference with `dirname::default_only_subdir_not_file_in_subdir` schema: the\nother schema ignores plain files. Thus, if a directory only contains `file1` and\n`subdir1`, then that other schema will return `subdir1` but this schema will not\nreturn a default value.\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-files-in` script). It is safer to use this schema when performing a\nnon-destructive action (e.g. `ls`) and/or operate in dry-run mode by default.\n\n",summary=>"Directory name, defaults to only subdirectory in current directory (if there is one)","x.perl.default_value_rules"=>["Path::only_subdir_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` into `/home/someuser/foo`. Normally this\nexpansion is done by a Unix shell, but sometimes your program receives an\nunexpanded path, e.g. when you get it from some config file.\n\nSee also more OS-specific schemas like `dirname::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 `filename`? The default completion\nrule. This schema's completion by default only includes directories.\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 directory name","x.completion"=>["dirname"]},'$var->{clsets_after_base}[0]'],"clsets_after_type.alt.merge.merged"=>['$var->{clsets_after_type}[0]','$var->{clsets_after_base}[0]'],resolve_path=>["str","dirname"],type=>"str",v=>2};$var->{clsets_after_type}[1]=$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_base}[0];$var}; | |
| 8 | |||
| 9 | 1 | 1; | |
| 10 | # ABSTRACT: Directory name, defaults to only subdirectory in current directory (if there is one) | ||
| 11 | |||
| 12 | __END__ |