/**
  * @param $env
  * @param $template
  */
 protected function init_from_template(File $env, $template)
 {
     if (!$env->isWritable()) {
         WP_CLI::error('Environment file is not readable at: ' . $env->path());
         return;
     }
     $template_path = $this->resolve_file_path($template);
     try {
         $env_template = File::at($template_path);
     } catch (\Exception $e) {
         WP_CLI::error("Template file is not readable at: {$template_path}");
     }
     WP_CLI::line('Initializing from template: ' . $env_template->path());
     copy($env_template->path(), $env->path());
     // we can't use WP-CLI --prompt because we're working off the template, not the synopsis
     if (!$this->get_flag('interactive')) {
         return;
     }
     $env->load();
     // reload the new copied data from template
     WP_CLI::line();
     WP_CLI::line('Interactive init');
     WP_CLI::line('Specify a new value for each key, or leave blank to keep the current value.');
     WP_CLI::line();
     $this->prompt_all($env);
 }
 /**
  * @test
  */
 public function it_can_check_for_the_existence_of_a_defined_var_by_key()
 {
     $env = File::at($this->get_fixture_path('env-basic'));
     $env->load();
     $this->assertTrue($env->hasKey('FOO'));
     $this->assertFalse($env->hasKey('HAS-NOT'));
 }
 /**
  * Load the environment file, while ensuring read permissions or die trying!
  *
  * @return File
  */
 protected function get_env_for_read_or_fail()
 {
     try {
         return File::at($this->resolve_file_path())->load();
     } catch (\Exception $e) {
         WP_CLI::error($e->getMessage());
     }
 }