Get rid of Path::Class ( that *does* feel good )
[dbsrgits/DBIx-Class.git] / script / dbicadmin
index 13c724d..414b582 100755 (executable)
@@ -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=<action>'],
+      ['op:s' => 'compatibility option all of the above can be supplied as --op=<action>'],
       ['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};