line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# TODO |
2
|
|
|
|
|
|
|
# - Install Module::Start::Flavor::Basic module on setup |
3
|
|
|
|
|
|
|
# - Support `module-start -install M::S::F::Foo` |
4
|
|
|
|
|
|
|
# - Finish start_module method |
5
|
|
|
|
|
|
|
# - Support inheritance in __config__ |
6
|
|
|
|
|
|
|
# - Release IO::All without Spiffy |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# XXX - Possible command line options: |
9
|
|
|
|
|
|
|
# --module= Explicit module_name |
10
|
|
|
|
|
|
|
# --flavor= Explicit flavor |
11
|
|
|
|
|
|
|
# -add Action to add a new module to a dist |
12
|
|
|
|
|
|
|
# -install Action to install a plugin |
13
|
|
|
|
|
|
|
# -setup Action to (re)do initial setup |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# XXX - Plugins to write: |
16
|
|
|
|
|
|
|
# - Module::Start::Flavor::MSFlavor |
17
|
|
|
|
|
|
|
# - Module::Start::Flavor::h2xs |
18
|
|
|
|
|
|
|
# - Module::Start::Flavor::Kwiki |
19
|
|
|
|
|
|
|
# - Module::Start::Flavor::Catalyst |
20
|
|
|
|
|
|
|
# - Module::Start::Flavor::Jifty |
21
|
|
|
|
|
|
|
# - Module::Start::Flavor::JSAN |
22
|
|
|
|
|
|
|
# - Module::Start::Flavor::PBP |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Module::Start; |
25
|
1
|
|
|
1
|
|
755
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
26
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
27
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
52
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
6
|
use base 'Module::Start::Base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
554
|
|
31
|
1
|
|
|
1
|
|
1057
|
use Class::Field 'field'; |
|
1
|
|
|
|
|
42736
|
|
|
1
|
|
|
|
|
65
|
|
32
|
1
|
|
|
1
|
|
972
|
use IO::All; |
|
1
|
|
|
|
|
46982
|
|
|
1
|
|
|
|
|
100
|
|
33
|
1
|
|
|
1
|
|
2232
|
use XXX; |
|
1
|
|
|
|
|
1846
|
|
|
1
|
|
|
|
|
6
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Module::Start object properties |
36
|
|
|
|
|
|
|
field 'config', -init => '$self->new_config_object'; |
37
|
|
|
|
|
|
|
field 'files', -init => '$self->read_data_files("Module::Start")'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Return usage message for module-start |
40
|
|
|
|
|
|
|
sub usage { |
41
|
0
|
|
|
0
|
0
|
|
<<'.'; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Usage: module-start module-name flavor |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Example: module-start Catalyst::Model::Funky catalyst |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Other Usages: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
module-start -setup |
50
|
|
|
|
|
|
|
module-start -add module-name flavor |
51
|
|
|
|
|
|
|
module-start -install flavor-plugin-name |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
. |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# module-start calls here to interpret and run the command line |
57
|
|
|
|
|
|
|
sub run { |
58
|
0
|
|
|
0
|
0
|
|
my ($self, @args) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$self->setup_site_configuration() |
61
|
|
|
|
|
|
|
unless $self->config->is_configured; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$self->exit("module-start is not properly configured") |
64
|
|
|
|
|
|
|
unless $self->config->is_configured; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my ($action, $arg_map) = $self->parse_options(@args); |
67
|
0
|
|
|
|
|
|
my $handler = "handle_$action"; |
68
|
0
|
0
|
|
|
|
|
$self->exit("No support for action '$action'") |
69
|
|
|
|
|
|
|
unless $self->can($handler); |
70
|
|
|
|
|
|
|
# unless ($module_name && $flavor) { |
71
|
|
|
|
|
|
|
# $self->exit($self->usage(), -noExitMsg); |
72
|
|
|
|
|
|
|
# } |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->$handler($arg_map); |
75
|
0
|
|
|
|
|
|
exit 0; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Start a new module or project from a flavor of template |
79
|
|
|
|
|
|
|
sub handle_start { |
80
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
81
|
0
|
0
|
|
|
|
|
$self->exit("No target module name specified for action 'start'") |
82
|
|
|
|
|
|
|
unless $args->{target}; |
83
|
0
|
0
|
|
|
|
|
$self->exit("No project flavor specified for action 'start'") |
84
|
|
|
|
|
|
|
unless $args->{flavor}; |
85
|
0
|
|
|
|
|
|
my $flavor = $args->{flavor}; |
86
|
0
|
|
|
|
|
|
my $base = $self->config->base_dir; |
87
|
0
|
0
|
|
|
|
|
$self->exit("Invalid flavor '$flavor' specified") |
88
|
|
|
|
|
|
|
unless -d "$base/templates/$flavor"; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
require Module::Start::Flavor; |
91
|
0
|
|
|
|
|
|
my $module_start_flavor = Module::Start::Flavor->new; |
92
|
0
|
|
|
|
|
|
$module_start_flavor->start_module($args); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$self->exit(sprintf("%s successfully started", |
95
|
|
|
|
|
|
|
$module_start_flavor->config->module_dist_name), |
96
|
|
|
|
|
|
|
-noExitMsg, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Create the initial module-start user environment |
101
|
|
|
|
|
|
|
sub setup_site_configuration { |
102
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
print "You don't appear to have module-start configured.\n"; |
105
|
0
|
0
|
|
|
|
|
unless ($self->q("Would you like to do that now?", 'y')) { |
106
|
0
|
|
|
|
|
|
$self->exit("Try running 'module-start -setup'"); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->prompt_for_author(); |
110
|
0
|
|
|
|
|
|
$self->prompt_for_email(); |
111
|
0
|
|
|
|
|
|
$self->config->write_config($self->files->{config}); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
require Module::Start::Flavor::Basic; |
114
|
0
|
|
|
|
|
|
Module::Start::Flavor::Basic->new->install_files; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
$self->config->is_configured(1); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Ask user for their full name |
120
|
|
|
|
|
|
|
sub prompt_for_author { |
121
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
122
|
0
|
|
|
|
|
|
my $author = $self->p("What is your full name?"); |
123
|
0
|
|
|
|
|
|
$self->config->author_full_name($author); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Ask user for email address |
127
|
|
|
|
|
|
|
sub prompt_for_email { |
128
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
129
|
0
|
|
|
|
|
|
my $email = $self->p("What is your email address?"); |
130
|
0
|
|
|
|
|
|
$self->config->author_email_address($email); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Parse command line input |
134
|
|
|
|
|
|
|
sub parse_options { |
135
|
0
|
|
|
0
|
0
|
|
my ($self, @args) = @_; |
136
|
0
|
|
|
|
|
|
my ($target, $flavor) = @args; |
137
|
|
|
|
|
|
|
# XXX add more action support here later. |
138
|
0
|
|
|
|
|
|
my $action = 'start'; |
139
|
0
|
|
|
|
|
|
my $arg_map = { |
140
|
|
|
|
|
|
|
flavor => $flavor, |
141
|
|
|
|
|
|
|
target => $target, |
142
|
|
|
|
|
|
|
}; |
143
|
0
|
|
|
|
|
|
return ($action, $arg_map); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__DATA__ |