| 1 | #!/usr/bin/env perl | ||
| 2 | # ABSTRACT: App::mkfeyorm wrapper script. Make skeleton code with Fey::ORM. | ||
| 3 | # PODNAME: mkfeyorm.pl | ||
| 4 | |||
| 5 | use utf8; | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use autodie; | ||
| 9 | use Getopt::Long::Descriptive; | ||
| 10 | use App::mkfeyorm; | ||
| 11 | |||
| 12 | my ( $opt, $usage ) = describe_options( | ||
| 13 | "%c %o ...", | ||
| 14 | [ 'schema|s=s', 'schema module name' ], | ||
| 15 | [ 'tables|t=s@', 'table module name list', { default => [] } ], | ||
| 16 | [ 'namespace|n=s', 'base namespace' ], | ||
| 17 | [ 'table_namespace=s', 'base table namespace' ], | ||
| 18 | [ 'schema_namespace=s', 'base schema namespace' ], | ||
| 19 | [ 'cache', 'turn on cache feature' ], | ||
| 20 | [ | ||
| 21 | 'output_path|o=s', | ||
| 22 | 'base directory (default: lib/)', | ||
| 23 | { default => 'lib' }, | ||
| 24 | ], | ||
| 25 | [], | ||
| 26 | [ 'verbose|v', 'print extra stuff', { default => 0 } ], | ||
| 27 | [ 'help|h', 'print usage message and exit' ], | ||
| 28 | ); | ||
| 29 | |||
| 30 | print($usage->text), exit if $opt->help; | ||
| 31 | print("must specify schema\n", $usage->text), exit unless $opt->schema; | ||
| 32 | print("must specify tables\n", $usage->text), exit unless $opt->tables; | ||
| 33 | |||
| 34 | my $app = App::mkfeyorm->new( | ||
| 35 | schema => $opt->schema, | ||
| 36 | tables => { | ||
| 37 | map { | ||
| 38 | my ( $table, $db_table ) = split /,/; | ||
| 39 | $table => $db_table; | ||
| 40 | } @{ $opt->tables } | ||
| 41 | }, | ||
| 42 | |||
| 43 | output_path => $opt->output_path, | ||
| 44 | namespace => $opt->namespace || q{}, | ||
| 45 | table_namespace => $opt->table_namespace || q{}, | ||
| 46 | schema_namespace => $opt->schema_namespace || q{}, | ||
| 47 | cache => $opt->cache || 0, | ||
| 48 | ); | ||
| 49 | |||
| 50 | $app->process; | ||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | =pod | ||
| 55 | |||
| 56 | =encoding utf-8 | ||
| 57 | |||
| 58 | =head1 NAME | ||
| 59 | |||
| 60 | mkfeyorm.pl - App::mkfeyorm wrapper script. Make skeleton code with Fey::ORM. | ||
| 61 | |||
| 62 | =head1 VERSION | ||
| 63 | |||
| 64 | version 0.010 | ||
| 65 | |||
| 66 | =head1 SYNOPSIS | ||
| 67 | |||
| 68 | If you want to generate C<My::Blog::Schema> | ||
| 69 | and C<My::Blog::Model::*> modules, then run following script. | ||
| 70 | |||
| 71 | $ mkfeyorm.pl \ | ||
| 72 | --namespace My::Blog \ | ||
| 73 | --schema Schema \ | ||
| 74 | --table_namespace Model \ | ||
| 75 | --tables User \ | ||
| 76 | --tables Role \ | ||
| 77 | --tables UserRole \ | ||
| 78 | --tables Post \ | ||
| 79 | --tables Comment | ||
| 80 | |||
| 81 | You can also specify database name explicitly. | ||
| 82 | |||
| 83 | $ mkfeyorm.pl \ | ||
| 84 | --namespace My::Blog \ | ||
| 85 | --table_namespace Model \ | ||
| 86 | --schema Schema \ | ||
| 87 | --tables User,user \ | ||
| 88 | --tables Role,role \ | ||
| 89 | --tables UserRole,user_role \ | ||
| 90 | --tables Post,post \ | ||
| 91 | --tables Comment,comment | ||
| 92 | |||
| 93 | =head1 DESCRIPTION | ||
| 94 | |||
| 95 | This is a L<App::mkfeyorm> wrapper script. | ||
| 96 | At least C<--schema> and C<--tables> options are needed. | ||
| 97 | |||
| 98 | =head1 OPTIONS | ||
| 99 | |||
| 100 | mkfeyorm.pl [-hnostv] [long options...] ... | ||
| 101 | -s --schema schema module name | ||
| 102 | -t --tables table module name list | ||
| 103 | -n --namespace base namespace | ||
| 104 | --table_namespace base table namespace | ||
| 105 | --schema_namespace base schema namespace | ||
| 106 | -o --output_path base directory (default: lib/) | ||
| 107 | |||
| 108 | -v --verbose print extra stuff | ||
| 109 | -h --help print usage message and exit | ||
| 110 | |||
| 111 | =head1 SEE ALSO | ||
| 112 | |||
| 113 | =over | ||
| 114 | |||
| 115 | =item L<Fey::ORM> | ||
| 116 | |||
| 117 | =item L<App::mkfeyorm> | ||
| 118 | |||
| 119 | =back | ||
| 120 | |||
| 121 | =head1 AUTHOR | ||
| 122 | |||
| 123 | Keedi Kim - κΉλν <keedi@cpan.org> | ||
| 124 | |||
| 125 | =head1 COPYRIGHT AND LICENSE | ||
| 126 | |||
| 127 | This software is copyright (c) 2011 by Keedi Kim. | ||
| 128 | |||
| 129 | This is free software; you can redistribute it and/or modify it under | ||
| 130 | the same terms as the Perl 5 programming language system itself. | ||
| 131 | |||
| 132 | =cut | ||
| 133 | |||
| 134 | |||
| 135 | __END__ |