Tests for dbicadmin.
[dbsrgits/DBIx-Class.git] / scripts / dbicadmin
similarity index 91%
rename from maint/dbicadmin
rename to scripts/dbicadmin
index 0f49332..e873745 100755 (executable)
@@ -12,6 +12,7 @@ $JSON::QuotApos = 1;
 GetOptions(
     'schema=s'  => \my $schema_class,
     'class=s'   => \my $resultset_class,
+    'connect=s' => \my $connect,
     'op=s'      => \my $op,
     'set=s'     => \my $set,
     'where=s'   => \my $where,
@@ -21,8 +22,13 @@ GetOptions(
     'trace'     => \my $trace,
     'quiet'     => \my $quiet,
     'help'      => \my $help,
+    'tlibs'      => \my $t_libs,
 );
 
+if ($t_libs) {
+    unshift( @INC, 't/lib', 'lib' );
+}
+
 pod2usage(1) if ($help);
 $ENV{DBIX_CLASS_STORAGE_DBI_DEBUG} = 1 if ($trace);
 
@@ -44,7 +50,10 @@ if ($op eq 'select') {
 die('No schema specified') if(!$schema_class);
 eval("require $schema_class");
 die('Unable to load schema') if ($@);
-my $schema = $schema_class->connect();
+$connect = jsonToObj( $connect ) if ($connect);
+my $schema = $schema_class->connect(
+    ( $connect ? @$connect : () )
+);
 
 die('No class specified') if(!$resultset_class);
 my $resultset = eval{ $schema->resultset($resultset_class) };
@@ -137,6 +146,12 @@ The name of your schema class.
 The name of the class, within your schema, that you want to run 
 the operation on.
 
+=head2 connect
+
+A JSON array to be passed to your schema class upon connecting.  
+The array will need to be compatible with whatever the DBIC 
+->connect() method requires.
+
 =head2 set
 
 This option must be valid JSON data string and is passed in to 
@@ -173,6 +188,11 @@ Do not display status messages.
 Turns on tracing on the DBI storage, thus printing SQL as it is 
 executed.
 
+=head2 tlibs
+
+This option is purely for testing during the DBIC installation.  Do 
+not use it.
+
 =head1 JSON
 
 JSON is a lightweight data-interchange format.  It allows you