Lines 28-34
sub print_usage {
Link Here
|
28 |
print <<USAGE; |
28 |
print <<USAGE; |
29 |
|
29 |
|
30 |
$basename |
30 |
$basename |
31 |
Load file in YAML format into database. |
31 |
Load file in YAML format into database, or convert it to SQL queries |
32 |
|
32 |
|
33 |
Usage: |
33 |
Usage: |
34 |
$0 [--file=FILE] |
34 |
$0 [--file=FILE] |
Lines 36-55
$0 -h
Link Here
|
36 |
-h, --help Show this help |
36 |
-h, --help Show this help |
37 |
-f, --file=FILE File to load. |
37 |
-f, --file=FILE File to load. |
38 |
--load Load the file into the database |
38 |
--load Load the file into the database |
|
|
39 |
--convert Convert to SQL |
39 |
|
40 |
|
40 |
USAGE |
41 |
USAGE |
41 |
} |
42 |
} |
42 |
|
43 |
|
43 |
# Getting parameters |
44 |
# Getting parameters |
44 |
my ( @files, $dump, $load, $help ); |
45 |
my ( @files, $dump, $load, $convert, $help ); |
45 |
|
46 |
|
46 |
GetOptions( |
47 |
GetOptions( |
47 |
'help|h' => \$help, |
48 |
'help|h' => \$help, |
48 |
'load' => \$load, |
49 |
'load' => \$load, |
|
|
50 |
'convert' => \$convert, |
49 |
'file|f=s@' => \@files, |
51 |
'file|f=s@' => \@files, |
50 |
) or print_usage, exit 1; |
52 |
) or print_usage, exit 1; |
51 |
|
53 |
|
52 |
if ($help or not @files or not $load) { |
54 |
if ($help or not @files or not ($convert or $load)) { |
53 |
print_usage; |
55 |
print_usage; |
54 |
exit; |
56 |
exit; |
55 |
} |
57 |
} |
Lines 61-63
if ( $load ) {
Link Here
|
61 |
say $error if $error; |
63 |
say $error if $error; |
62 |
} |
64 |
} |
63 |
} |
65 |
} |
64 |
- |
66 |
if ( $convert ) { |
|
|
67 |
for my $f ( @files ) { |
68 |
say $installer->yml2sql($f); |
69 |
} |
70 |
} |