line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UR::Namespace::Command::Init; |
2
|
1
|
|
|
1
|
|
22
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
24
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
3
|
use UR; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
UR::Object::Type->define( |
8
|
|
|
|
|
|
|
class_name => __PACKAGE__, |
9
|
|
|
|
|
|
|
is => "Command", |
10
|
|
|
|
|
|
|
has => [ |
11
|
|
|
|
|
|
|
namespace => { |
12
|
|
|
|
|
|
|
is => 'Text', |
13
|
|
|
|
|
|
|
shell_args_position => 1, |
14
|
|
|
|
|
|
|
doc => 'the name of the namespace/app to create' |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
db => { |
17
|
|
|
|
|
|
|
is => 'Text', |
18
|
|
|
|
|
|
|
is_optional => 1, |
19
|
|
|
|
|
|
|
shell_args_position => 2, |
20
|
|
|
|
|
|
|
doc => 'the (optional) DBI connection string for the primary data source', |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
], |
23
|
|
|
|
|
|
|
doc => 'create a new ur app with default classes in place', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
0
|
|
sub sub_command_sort_position { 1 } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub execute { |
29
|
0
|
|
|
0
|
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my $c; |
31
|
0
|
|
|
|
|
|
my $t = UR::Context::Transaction->begin(); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$self->status_message("*** ur define namespace " . $self->namespace); |
34
|
0
|
0
|
|
|
|
|
UR::Namespace::Command::Define::Namespace->execute(nsname => $self->namespace)->result or die; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ($self->db) { |
37
|
0
|
|
|
|
|
|
$self->status_message("\n*** cd " . $self->namespace); |
38
|
0
|
0
|
0
|
|
|
|
chdir $self->namespace or ($self->error_message("error changing to namespace dir? $!") and die); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self->status_message("\n*** ur define db " . $self->db); |
41
|
0
|
0
|
|
|
|
|
$c = UR::Namespace::Command::Define::Db->create(uri => $self->db) or return; |
42
|
0
|
|
|
|
|
|
$c->dump_status_messages(1); |
43
|
0
|
0
|
|
|
|
|
$c->execute() or die; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$self->status_message("\n*** ur update classes-from-db"); |
46
|
0
|
|
|
|
|
|
$c = UR::Namespace::Command::Update::ClassesFromDb->create(); |
47
|
0
|
|
|
|
|
|
$c->dump_status_messages(1); |
48
|
0
|
0
|
|
|
|
|
$c->execute() or die; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
0
|
|
|
|
|
|
$self->status_message("next: cd " . $self->namespace); |
52
|
0
|
|
|
|
|
|
$self->status_message("then: ur define db DSN"); |
53
|
0
|
|
|
|
|
|
$self->status_message("then: ur update classes-from-db"); |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
$t->commit; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|