line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::VTide::Command::Init; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2016-01-30 15:06:31 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
995
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
2560
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
64
|
|
11
|
1
|
|
|
1
|
|
11
|
use version; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
12
|
1
|
|
|
1
|
|
62
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
13
|
1
|
|
|
1
|
|
6
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
14
|
1
|
|
|
1
|
|
336
|
use File::chdir; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
15
|
1
|
|
|
1
|
|
8
|
use Path::Tiny; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
57
|
|
16
|
1
|
|
|
1
|
|
6
|
use YAML::Syck; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
468
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
extends 'App::VTide::Command'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = version->new('1.0.4'); |
21
|
|
|
|
|
|
|
our $NAME = 'init'; |
22
|
|
|
|
|
|
|
our $OPTIONS = [ |
23
|
|
|
|
|
|
|
'name|n=s', |
24
|
|
|
|
|
|
|
'dir|d=s', |
25
|
|
|
|
|
|
|
'windows|w=i', |
26
|
|
|
|
|
|
|
'force|f!', |
27
|
|
|
|
|
|
|
'verbose|v+', |
28
|
|
|
|
|
|
|
]; |
29
|
0
|
|
|
0
|
1
|
|
sub details_sub { return ( $NAME, $OPTIONS )}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub run { |
32
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
33
|
0
|
|
0
|
|
|
|
my $dir = path( $self->defaults->{dir} || '.' )->absolute; |
34
|
0
|
|
|
|
|
|
my $file = $dir->path( '.vtide.yml' ); |
35
|
0
|
|
0
|
|
|
|
my $count = $self->defaults->{windows} || 4; |
36
|
0
|
|
0
|
|
|
|
my $name = $self->defaults->{name} || $dir->basename; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->hooks->run('init_name', \$name); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $config = { |
41
|
|
|
|
|
|
|
name => $name, |
42
|
|
|
|
|
|
|
count => $count, |
43
|
|
|
|
|
|
|
default => { |
44
|
|
|
|
|
|
|
restart => 0, |
45
|
|
|
|
|
|
|
wait => 0, |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
editor => { |
48
|
|
|
|
|
|
|
files => { |
49
|
|
|
|
|
|
|
eg => [qw/some-file.eg/], |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
terminals => { |
53
|
0
|
|
|
|
|
|
map { $_ => [] } 2 .. $count |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->hooks->run('init_config', $config); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ( -f $file ) { |
60
|
0
|
0
|
|
|
|
|
if ( ! $self->defaults->{force} ) { |
61
|
0
|
|
|
|
|
|
die "The config file '.vtide.yml' already exists wont overwrite without --force!\n"; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
warn "Overwritting '.vtide.yml'\n"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $yaml = Dump( $config ); |
67
|
0
|
|
|
|
|
|
my $now = localtime; |
68
|
0
|
|
|
|
|
|
$yaml =~ s/^(---\s*\n)/$1# Create by App::VTide::Command::Init $now VERSION $App::VTide::Command::Init::VERSION\n/xms; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$file->spew($yaml); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->save_session( $name, $dir ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub auto_complete { |
78
|
0
|
|
|
0
|
1
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
App::VTide::Command::Init - Initialize an session configuration file |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This documentation refers to App::VTide::Command::Init version 1.0.4 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
vtide init [(-n|--name) name] [(-d|--dir) dir] [(-w|--windows) num] |
96
|
|
|
|
|
|
|
vtide init [--help|--man] |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
OPTIONS: |
99
|
|
|
|
|
|
|
-n --name[=]str Name of the project (Default is the current directory name) |
100
|
|
|
|
|
|
|
-d --dir[=]str Use this as the current directory |
101
|
|
|
|
|
|
|
-w --windows[=]int |
102
|
|
|
|
|
|
|
The number of tmux windows to create when starting |
103
|
|
|
|
|
|
|
-f --force Force the overwritting of existing .vtide.yml file when found |
104
|
|
|
|
|
|
|
--help Show this help |
105
|
|
|
|
|
|
|
--man Show the full man page |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 C<run ()> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Initialize the configuration file |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 C<auto_complete ()> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
NoOp. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<details_sub ()> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the commands details. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 HOOKS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 C<init_config ($config)> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This hook is called after the default configuration is created but |
128
|
|
|
|
|
|
|
before it's saved. The variable C<$config> is a reference so modifications |
129
|
|
|
|
|
|
|
to it will be written to the generated C<.vtide.yml> file. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 C<init_name ($name)> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This allows the modification of the generated project name. The variable |
134
|
|
|
|
|
|
|
C<$name> is a string reference so it can be modified. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
There are no known bugs in this module. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Patches are welcome. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright (c) 2016 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
159
|
|
|
|
|
|
|
All rights reserved. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
162
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
163
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
164
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
165
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |