line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::VTide::Command::Conf; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2016-02-08 10:42:09 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1042
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
2598
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
11
|
1
|
|
|
1
|
|
5
|
use version; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
12
|
1
|
|
|
1
|
|
59
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
13
|
1
|
|
|
1
|
|
7
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
14
|
1
|
|
|
1
|
|
354
|
use YAML::Syck qw/ Dump /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
15
|
1
|
|
|
1
|
|
508
|
use Array::Utils qw/intersect/; |
|
1
|
|
|
|
|
445
|
|
|
1
|
|
|
|
|
1141
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
extends 'App::VTide::Command'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = version->new('1.0.4'); |
20
|
|
|
|
|
|
|
our $NAME = 'conf'; |
21
|
|
|
|
|
|
|
our $OPTIONS = [ 'env|e', 'terms|t', 'which|w=s', 'test|T!', 'verbose|v+', ]; |
22
|
0
|
|
|
0
|
1
|
|
sub details_sub { return ( $NAME, $OPTIONS ) } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _alphanum { |
25
|
0
|
|
|
0
|
|
|
my $A = $a; |
26
|
0
|
|
|
|
|
|
my $B = $b; |
27
|
0
|
|
|
|
|
|
$A =~ s/(\d+)/sprintf "%05i", $1/egxms; |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$B =~ s/(\d+)/sprintf "%05i", $1/egxms; |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
return $A cmp $B; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub run { |
33
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if ( $self->defaults->{env} ) { |
36
|
|
|
|
|
|
|
my %env = ( |
37
|
0
|
0
|
|
|
|
|
%{ $self->config->get->{default}{env} || {} }, |
38
|
0
|
|
|
|
|
|
%{ $self->config->get->{terminals}{ $ENV{VTIDE_TERM} }{env} || {} |
39
|
0
|
0
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
); |
41
|
0
|
|
|
|
|
|
for my $env ( sort keys %ENV ) { |
42
|
0
|
0
|
0
|
|
|
|
next if $env !~ /VTIDE/ && !exists $env{$env}; |
43
|
0
|
|
|
|
|
|
printf "%-12s : %s\n", $env, $ENV{$env}; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
print "\n"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ( $self->defaults->{which} ) { |
49
|
0
|
|
|
|
|
|
return $self->which( $self->defaults->{which} ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $data |
53
|
|
|
|
|
|
|
= $self->defaults->{terms} |
54
|
|
|
|
|
|
|
? $self->config->get->{terminals} |
55
|
0
|
0
|
|
|
|
|
: $self->config->get->{editor}{files}; |
56
|
0
|
|
|
|
|
|
my @files = sort _alphanum keys %{$data}; |
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
print $self->defaults->{terms} |
59
|
0
|
0
|
|
|
|
|
? "Terminals configured:\n" |
60
|
|
|
|
|
|
|
: "File groups:\n"; |
61
|
0
|
0
|
|
|
|
|
if ( $self->defaults->{verbose} ) { |
62
|
0
|
|
|
|
|
|
for my $file (@files) { |
63
|
0
|
|
|
|
|
|
my $data = Dump( $data->{$file} ); |
64
|
0
|
|
|
|
|
|
$data =~ s/^---//xms; |
65
|
0
|
|
|
|
|
|
print $file, $data, "\n"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
|
|
|
|
|
print join "\n", @files, ''; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub which { |
76
|
0
|
|
|
0
|
1
|
|
my ( $self, $which ) = @_; |
77
|
0
|
|
|
|
|
|
my $term = $self->config->get->{terminals}; |
78
|
0
|
|
|
|
|
|
my $file = $self->config->get->{editor}{files}; |
79
|
0
|
|
|
|
|
|
my ( %files, %groups, %terms ); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
for my $group ( keys %$file ) { |
82
|
0
|
|
|
|
|
|
my @found = grep {/$which/} |
83
|
0
|
|
|
|
|
|
@{ $file->{$group} }, |
84
|
0
|
|
|
|
|
|
map { $self->_dglob($_) } @{ $file->{$group} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
next if !@found; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
for my $found (@found) { |
88
|
0
|
|
|
|
|
|
$files{$found}++; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
|
$groups{$group}++; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my @files = sort keys %files; |
94
|
0
|
|
|
|
|
|
my @groups = sort keys %groups; |
95
|
0
|
|
|
|
|
|
my @terms; |
96
|
0
|
|
|
|
|
|
for my $terminal ( sort keys %$term ) { |
97
|
|
|
|
|
|
|
my $edit |
98
|
|
|
|
|
|
|
= !$term->{$terminal}{edit} ? [] |
99
|
|
|
|
|
|
|
: !ref $term->{$terminal}{edit} ? [ $term->{$terminal}{edit} ] |
100
|
0
|
0
|
|
|
|
|
: $term->{$terminal}{edit}; |
|
|
0
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my @found = ( ( intersect @files, @$edit ), |
103
|
|
|
|
|
|
|
( intersect @groups, @$edit ), ); |
104
|
0
|
0
|
|
|
|
|
next if !@found; |
105
|
0
|
|
|
|
|
|
push @terms, $terminal; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
if (@files) { |
109
|
0
|
|
|
|
|
|
print "Files: " . ( join ', ', @files ) . "\n"; |
110
|
0
|
|
|
|
|
|
print "Groups: " . ( join ', ', @groups ) . "\n"; |
111
|
0
|
0
|
|
|
|
|
print "Terminals: " . ( join ', ', @terms ) . "\n" if @terms; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
else { |
114
|
0
|
|
|
|
|
|
print "Not found\n"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub auto_complete { |
121
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my $env = $self->options->files->[-1]; |
124
|
0
|
|
|
|
|
|
my @files = sort keys %{ $self->config->get->{editor}{files} }; |
|
0
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
print join ' ', grep { $env ne 'conf' ? /^$env/xms : 1 } @files; |
|
0
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 NAME |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
App::VTide::Command::Conf - Show the current VTide configuration and environment |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 VERSION |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This documentation refers to App::VTide::Command::Conf version 1.0.4 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SYNOPSIS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
vtide conf [-e|--env] [-t|--terms] [-v|--verbose] |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
OPTIONS |
148
|
|
|
|
|
|
|
-e --env Show the current VTIide environment |
149
|
|
|
|
|
|
|
-t --terms Show the terminal configurations |
150
|
|
|
|
|
|
|
-w --which[=]glob-name |
151
|
|
|
|
|
|
|
Show the files found by "glob-name" |
152
|
|
|
|
|
|
|
-v --verbose Show environment as well as config |
153
|
|
|
|
|
|
|
--help Show this help |
154
|
|
|
|
|
|
|
--man Show the full man page |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 DESCRIPTION |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This module provide command line option to view the current configuration |
159
|
|
|
|
|
|
|
of a L<vtide> project. This can be helpful when wanting to edit file and |
160
|
|
|
|
|
|
|
you can't remember which file group has the files you are interested. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 C<run ()> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Show's the current files configuration |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 C<which ( $what )> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Finds which terminals / file globs C<$what> belongs to. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 C<auto_complete ()> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Auto completes sub-commands that can have help shown |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 C<details_sub ()> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Returns the commands details |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
There are no known bugs in this module. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Patches are welcome. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Copyright (c) 2016 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
203
|
|
|
|
|
|
|
All rights reserved. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
206
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
207
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
208
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
209
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |