/**
  * @param $tsv
  * @param $handle
  * @param Template $template
  */
 protected static function put_body($tsv, $handle, $template)
 {
     foreach ($tsv['body'] as $row) {
         $text = $template->convert($row);
         if ($text !== false) {
             File::write($handle, $text . "\n\n");
         }
     }
 }
 public static function parse_args($argc, $argv)
 {
     $res = ['status' => false, 'command' => 'main'];
     // command
     if ($argc < 2) {
         return $res;
     }
     $command = $argv[1];
     if (array_search($command, self::$commands) === false) {
         return $res;
     }
     $res['command'] = $command;
     // other args
     if ($argc < self::REQUIRE_LENGTH) {
         return $res;
     }
     $opts = $res['opts'] = Option::getopt();
     if ($argc === false) {
         return $res;
     }
     // source_file
     $source_handle = File::open($opts['s'], 'r');
     if ($source_handle === false) {
         return $res;
     }
     $res['opts']['source_handle'] = $source_handle;
     // output_file
     $output_handle = File::open($opts['o'], $opts['a'] ? 'r+' : 'w');
     if ($output_handle === false) {
         return $res;
     }
     $res['opts']['output_handle'] = $output_handle;
     // template file
     $template_handle = File::open($opts['t'], 'r');
     if ($template_handle === false) {
         return $res;
     }
     $res['opts']['template_handle'] = $template_handle;
     // success!
     $res['status'] = true;
     return $res;
 }