X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fdbicadmin;h=414b5829778c04afda9588f6cf9cddd4dc61746a;hb=20c0d57b670cd7b739b8f8a6a72223b1eb53e531;hp=13c724dd5ae7453f4fb5c8946d6163ed4b2b1c33;hpb=e2633789f6faa803867476366674aa531597af81;p=dbsrgits%2FDBIx-Class.git diff --git a/script/dbicadmin b/script/dbicadmin index 13c724d..414b582 100755 --- a/script/dbicadmin +++ b/script/dbicadmin @@ -4,11 +4,10 @@ use strict; use warnings; BEGIN { - use DBIx::Class; - die ( 'The following modules are required for the dbicadmin utility: ' - . DBIx::Class::Optional::Dependencies->req_missing_for ('admin_script') - . "\n" - ) unless DBIx::Class::Optional::Dependencies->req_ok_for ('admin_script'); + require DBIx::Class::Optional::Dependencies; + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('admin_script') ) { + die "The following modules are required for the dbicadmin utility: $missing\n"; + } } use DBIx::Class::Admin::Descriptive; @@ -41,7 +40,7 @@ my ($opts, $usage) = describe_options( ['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='], + ['op:s' => 'compatibility option all of the above can be supplied as --op='], ['help' => 'display this help', { implies => { schema_class => '__dummy__' } } ], ['documentation-as-pod:s' => 'hidden', { implies => { schema_class => '__dummy__' } } ], ], required => 1 }], @@ -72,21 +71,21 @@ if(defined (my $fn = $opts->{documentation_as_pod}) ) { $usage->synopsis($synopsis_text); $usage->short_description($short_description); + my $fh; if ($fn) { - require File::Spec; - require File::Path; - my $dir = File::Spec->catpath( (File::Spec->splitpath($fn))[0,1] ); - File::Path::mkpath([$dir]); + require DBIx::Class::_Util; + DBIx::Class::_Util::mkdir_p( DBIx::Class::_Util::parent_dir( $fn ) ); + open( $fh, '>', $fn ) or die "Unable to open $fn: $!\n"; + } + else { + $fh = \*STDOUT; } - 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"; + print $fh "\n"; + print $fh $usage->pod; + print $fh "\n"; - close STDOUT if $fn; + close $fh if $fn; exit 0; } @@ -100,7 +99,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};