| 1 | #============================================================================= | ||
| 2 | # | ||
| 3 | # Module: Term::CLI::Argument::Filename | ||
| 4 | # | ||
| 5 | # Description: Class for file name arguments in Term::CLI | ||
| 6 | # | ||
| 7 | # Author: Steven Bakker (SBAKKER), <sbakker@cpan.org> | ||
| 8 | # Created: 23/01/18 | ||
| 9 | # | ||
| 10 | # Copyright (c) 2018 Steven Bakker | ||
| 11 | # | ||
| 12 | # This module is free software; you can redistribute it and/or modify | ||
| 13 | # it under the same terms as Perl itself. See "perldoc perlartistic." | ||
| 14 | # | ||
| 15 | # This software is distributed in the hope that it will be useful, | ||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 18 | # | ||
| 19 | #============================================================================= | ||
| 20 | |||
| 21 | use 5.014_001; | ||
| 22 | |||
| 23 | package Term::CLI::Argument::Filename 0.051003 { | ||
| 24 | |||
| 25 | use Modern::Perl 1.20140107; | ||
| 26 | use Moo 1.000001; | ||
| 27 | use namespace::clean 0.25; | ||
| 28 | |||
| 29 | extends 'Term::CLI::Argument'; | ||
| 30 | |||
| 31 | sub complete { | ||
| 32 | my $self = shift; | ||
| 33 | my $partial = shift; | ||
| 34 | |||
| 35 | my $func_ref = $self->term->Attribs->{filename_completion_function} | ||
| 36 | or return; | ||
| 37 | |||
| 38 | my $state = 0; | ||
| 39 | my @list; | ||
| 40 | while (my $f = $func_ref->($partial, $state)) { | ||
| 41 | push @list, $f; | ||
| 42 | $state = 1; | ||
| 43 | } | ||
| 44 | return @list; | ||
| 45 | } | ||
| 46 | |||
| 47 | } | ||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | __END__ |