opt deps for dbicdump config and test
[dbsrgits/DBIx-Class-Schema-Loader.git] / script / dbicdump
index c6fdf3a..cb97638 100644 (file)
@@ -33,7 +33,7 @@ On Windows that would be:
     -o preserve_case=1 ^
     MyApp::Schema dbi:mysql:database=foo user pass "{ quote_char => q{`} }"
     
-Configuration Files must have schema_class and connect_info sections,
+Configuration files must have schema_class and connect_info sections,
 an example of a general config file is as follows:
 
     schema_class MyApp::Schema
@@ -51,6 +51,8 @@ an example of a general config file is as follows:
         components  TimeStamp
     </loader_options>
 
+Using a config file requires L<Config::Any> installed.
+
 =head1 DESCRIPTION
 
 Dbicdump generates a L<DBIx::Class> schema using
@@ -86,12 +88,10 @@ under the same terms as Perl itself.
 use strict;
 use warnings;
 use Getopt::Long;
-use Config::Any;
-
 use Pod::Usage;
-
-use DBIx::Class::Schema::Loader qw/ make_schema_at /;
-require DBIx::Class::Schema::Loader::Base;
+use DBIx::Class::Schema::Loader 'make_schema_at';
+use DBIx::Class::Schema::Loader::Base ();
+use DBIx::Class::Schema::Loader::Optional::Dependencies ();
 
 my $loader_options;
 
@@ -99,7 +99,13 @@ GetOptions( 'loader-option|o=s%' => \&handle_option );
 $loader_options->{dump_directory} ||= '.';
 
 if (@ARGV == 1) {
+    if (not DBIx::Class::Schema::Loader::Optional::Dependencies->req_ok_for('dbicdump_config')) {
+        die sprintf "You must install the following CPAN modules to use a config file with dbicdump: %s.\n",
+            DBIx::Class::Schema::Loader::Optional::Dependencies->req_missing_for('dbicdump_config');
+    }
+
     my $configuration_file = shift @ARGV;
+
     my $configurations =
       Config::Any->load_files( {
             use_ext => 1,