Configurable config file
[p5sagit/Oyster.git] / lib / Dist / Zilla / App / Command / provision.pm
index e394b67..68fe099 100644 (file)
@@ -4,7 +4,7 @@ package Dist::Zilla::App::Command::provision;
 BEGIN {
   $Dist::Zilla::App::Command::provision::VERSION = '0.1';
 }
-# ABSTRACT: release your dist to the CPAN
+# ABSTRACT: provision a new Oyster VM
 use Dist::Zilla::App -command;
 use Moose;
 use Config::Any;
@@ -16,6 +16,7 @@ sub abstract { 'provision a new Oyster VM' }
 
 sub opt_spec {
   [ 'name=s'     => 'the name of the VM to create' ],
+  [ 'config=s'   => 'the name of the config file to use, default ./oyster.conf' ],
 }
 
 sub execute {
@@ -25,7 +26,7 @@ sub execute {
 
   my $name = $opt->name
     or die "No name provided!";
-  my @config_files = ( './oyster.conf' ); # TODO make configurable
+  my @config_files = ($opt->name or './oyster.conf');
 
   my $cfg = Config::Any->load_files({ files => \@config_files, use_ext => 0 });
   ($cfg) = values %{ $cfg->[0] }; # FIX with ::JFDI or similar
@@ -45,10 +46,11 @@ sub execute {
   $hash{size}    ||= 1;  # id 1 - ram 256 MiB - disk 10 GiB
   $hash{image}   ||= 69; # id 69 - Ubuntu 10.10 (meerkat)
 
-  warn Dumper(\%hash); use Data::Dumper;
+  use Data::Dumper; warn "Config hash: ", Dumper(\%hash);
 
   my $server = Oyster::Provision->new(
         name => $name,
+        config => \%hash,
         %hash,
   );
   $server->create;