From: Gordon Irving Date: Sat, 20 Feb 2010 19:56:16 +0000 (+0000) Subject: dbicadmin: use subclassed G:L:D to generate some pod X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5279977117b2716775c8faaa90b0ef825fae024;p=dbsrgits%2FDBIx-Class-Historic.git dbicadmin: use subclassed G:L:D to generate some pod --- diff --git a/script/dbicadmin b/script/dbicadmin index 2b6a456..c097c71 100755 --- a/script/dbicadmin +++ b/script/dbicadmin @@ -10,24 +10,40 @@ BEGIN { ) unless DBIx::Class::Optional::Dependencies->req_ok_for ('admin_script'); } -use Getopt::Long::Descriptive; +use DBIx::Class::Admin::Descriptive; +#use Getopt::Long::Descriptive; use DBIx::Class::Admin; +my $short_description = "utility for administrating DBIx::Class schemata"; +my $synopsis_text =qq{ + deploy a schema to a database + %c --schema=MyApp::Schema \ + --connect='["dbi:SQLite:my.db", "", ""]' \ + --deploy + + update an existing record + %c --schema=MyApp::Schema --class=Employee \ + --connect='["dbi:SQLite:my.db", "", ""]' \ + --op=update --set='{ "name": "New_Employee" }' +} +; + my ($opts, $usage) = describe_options( - "%c: %o", + "%c: %o", ( ['Actions'], ["action" => hidden => { one_of => [ ['create|c' => 'Create version diffs needs preversion',], - ['upgrade|u' => 'Upgrade the database to the current schema '], - ['install|i' => 'Install the schema to the database',], + ['upgrade|U' => 'Upgrade the database to the current schema '], + ['install|I' => 'Install the schema version tables to an existing database',], ['deploy|d' => 'Deploy the schema to the database',], ['select|s' => 'Select data from the schema', ], ['insert|i' => 'Insert data into the schema', ], ['update|u' => 'Update data in the schema', ], ['delete|D' => 'Delete data from the schema',], ['op:s' => 'compatiblity option all of the above can be suppied as --op='], - ['help|h' => 'display this help'], + ['help|h' => 'display this help', { implies => { schema_class => 'main' } } ], + ['pod' => 'Output this usage as pod', { implies => { schema_class => 'main' } } ], ], required=> 1 }], ['Options'], ['schema-class|schema|C:s' => 'The class of the schema to load', { required => 1 } ], @@ -41,7 +57,6 @@ my ($opts, $usage) = describe_options( ['version|v:i' => 'Supply a version install'], ['preversion|p:s' => 'The previous version to diff against',], ['set:s' => 'JSON data used to perform data operations' ], - ['lib|I:s' => 'Additonal library path to search in'], ['attrs:s' => 'JSON string to be used for the second argument for search'], ['where:s' => 'JSON string to be used for the where clause of search'], ['force' => 'Be forceful with some operations'], @@ -52,6 +67,17 @@ my ($opts, $usage) = describe_options( die "please only use one of --config or --connect-info\n" if ($opts->{config} and $opts->{connect_info}); +if($opts->{pod}) { + $usage->synopsis($synopsis_text); + $usage->short_description($short_description); + print $usage->pod(); + exit 0; +} + +if($opts->{help}) { + $usage->die(); +} + # option compatability mangle if($opts->{connect}) { $opts->{connect_info} = delete $opts->{connect}; @@ -83,6 +109,19 @@ if ($action eq 'select') { print $csv->string()."\n"; } } +__END__ + +=begin pod_begin + +BEGIN MARKER FOR DYNAMIC POD + +=end pod_begin + +=begin pod_end + +END MARKER FOR DYNAMIC POD + +=end pod_end =head1 AUTHOR @@ -93,3 +132,5 @@ See L. You may distribute this code under the same terms as Perl itself =cut + +# vim: et ft=perl