| 1 | package Sah::Schema::filename::default_only_file_not_dir_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) (subdirectories ignored)', | ||
| 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 (subdirectories are ignored). | ||
| 17 | |||
| 18 | Difference with `filename::default_only_file_in_subdir` schema: the other schema | ||
| 19 | does not ignore subdirectories. Thus, if a directory only contains `file1` and | ||
| 20 | `subdir1`, then that other schema will not return `file1` but this schema will. | ||
| 21 | |||
| 22 | Note: be careful when using this schema for actions that are destructive, | ||
| 23 | because a user can perform those actions without giving an argument (e.g. in a | ||
| 24 | `delete-file` script). It is safer to use this schema when performing a | ||
| 25 | non-destructive action (e.g. `checksum`) and/or operate in dry-run mode by | ||
| 26 | default. | ||
| 27 | |||
| 28 | MARKDOWN | ||
| 29 | 'x.perl.default_value_rules' => ['Path::only_file_not_dir_in_curdir'], | ||
| 30 | }]; | ||
| 31 | |||
| 32 | 1 | 1; | |
| 33 | # ABSTRACT: File name, defaults to only file in current directory (if there is one) (subdirectories ignored) | ||
| 34 | |||
| 35 | __END__ | ||