X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fdbicadmin;h=e6066fbc435fba92966f1af51d7ad40ded2060e8;hb=f1b1d954fa373d7aabd24de2712cfa141f030540;hp=e167ee4d1f210e77680e661bc77a37bcd5de11dd;hpb=7b71391b3752ec823c7510403c6b59b0be4957ce;p=dbsrgits%2FDBIx-Class.git diff --git a/script/dbicadmin b/script/dbicadmin index e167ee4..e6066fb 100755 --- a/script/dbicadmin +++ b/script/dbicadmin @@ -33,24 +33,24 @@ my ($opts, $usage) = describe_options( ( ['Actions'], ["action" => hidden => { one_of => [ - ['create' => 'Create version diffs needs preversion',], - ['upgrade' => 'Upgrade the database to the current schema '], - ['install' => 'Install the schema version tables to an existing database',], - ['deploy' => 'Deploy the schema to the database',], - ['select' => 'Select data from the schema', ], - ['insert' => 'Insert data into the schema', ], - ['update' => 'Update data in the schema', ], - ['delete' => 'Delete data from the schema',], - ['op:s' => 'compatiblity option all of the above can be suppied as --op='], + ['create' => 'Create version diffs needs preversion'], + ['upgrade' => 'Upgrade the database to the current schema'], + ['install' => 'Install the schema version tables to an existing database'], + ['deploy' => 'Deploy the schema to the database'], + ['select' => 'Select data from the schema'], + ['insert' => 'Insert data into the schema'], + ['update' => 'Update data in the schema'], + ['delete' => 'Delete data from the schema'], + ['op:s' => 'compatibility option all of the above can be supplied as --op='], ['help' => 'display this help', { implies => { schema_class => '__dummy__' } } ], - ['selfinject-pod' => 'hidden', { implies => { schema_class => '__dummy__' } } ], + ['documentation-as-pod:s' => 'hidden', { implies => { schema_class => '__dummy__' } } ], ], required => 1 }], ['Arguments'], ["configuration" => hidden => { one_of => [ ['config-file|config:s' => 'Supply the config file for parsing by Config::Any', { depends => 'config_stanza'} ], ['connect-info:s%' => 'Supply the connect info as trailing options e.g. --connect-info dsn= user= password=' ], ['connect:s' => 'Supply the connect info as a JSON-encoded structure, e.g. an --connect=["dsn","user","pass"]'], - ], required => 1 }], + ] }], ['schema-class:s' => 'The class of the schema to load', { required => 1 } ], ['config-stanza:s' => 'Where in the config to find the connection_info, supply in form MyApp::Model::DB',], ['resultset|resultset-class|class:s' => 'The resultset to operate on for data manipulation' ], @@ -68,23 +68,26 @@ my ($opts, $usage) = describe_options( ) ); -if($opts->{selfinject_pod}) { - - die "This is an internal method, do not call!!!\n" - unless $ENV{MAKELEVEL}; - - $usage->synopsis($synopsis_text); - $usage->short_description($short_description); - exec ( - $^X, - qw/-p -0777 -i -e/, - ( - 's/^# auto_pod_begin.*^# auto_pod_end/' - . quotemeta($usage->pod) - . '/ms' - ), - __FILE__ - ); +if(defined (my $fn = $opts->{documentation_as_pod}) ) { + $usage->synopsis($synopsis_text); + $usage->short_description($short_description); + + if ($fn) { + require File::Spec; + require File::Path; + my $dir = File::Spec->catpath( (File::Spec->splitpath($fn))[0,1] ); + File::Path::mkpath([$dir]); + } + + local *STDOUT if $fn; + open (STDOUT, '>', $fn) or die "Unable to open $fn: $!\n" if $fn; + + print STDOUT "\n"; + print STDOUT $usage->pod; + print STDOUT "\n"; + + close STDOUT if $fn; + exit 0; } # FIXME - lowercasing will eventually go away when Getopt::Long::Descriptive is fixed @@ -97,7 +100,7 @@ if($opts->{help}) { $usage->die(); } -# option compatability mangle +# option compatibility mangle # (can not be joined in the spec, one is s% the other is s) if($opts->{connect}) { $opts->{connect_info} = delete $opts->{connect}; @@ -129,13 +132,6 @@ if ($action eq 'select') { } } +1; __END__ - -# auto_pod_begin -# -# This will be replaced by the actual pod when selfinject-pod is invoked -# -# auto_pod_end - -# vim: et ft=perl