import {exec} from 'child_process';

const JPG_AVAILABLE = 'jhead -V';
const JPG_RENAME = `jhead -n{format} {filePaths}`;
const extension = 'jpg';

export default class {
  constructor(logger) {
    this.logger = logger;
    this.extension = extension;
  }

  // evaluate if jhead can be executed
  isAvailable() {
    return new Promise((resolve, reject) => {
      exec(JPG_AVAILABLE, error => {
        if (error) {
          resolve(false);
        }
        resolve(true);
      });
    });
  }

  // rename files using pattern
  rename(filePaths, format) {
    
  }
}

@@ -5,16 +5,23 @@
 rt %7Bexec
+, spawn
 %7D from '
@@ -41,31 +41,74 @@
 ';%0D%0A
-%0D%0Aconst JPG_AVAILABLE =
+import %7Bformat%7D from 'string-template'%0D%0A%0D%0A// Test availability%0D%0A//
  'jh
@@ -118,61 +118,89 @@
  -V'
-;
 %0D%0A
-const JPG_RENAME = %60jhead -n%7Bformat%7D %7BfilePaths%7D%60;
+%0D%0A// Rename files%0D%0A// 'jhead -n%25YYYY%25MM%25dd-%25HH%25MM%25SS file1.jpg file2.jpg ...'%0D%0A
 %0D%0Aco
@@ -457,26 +457,53 @@
     
-exec(JPG_AVAILABLE
+var command = 'jhead -V';%0D%0A      exec(command
 , er
@@ -682,25 +682,353 @@
 , format
-) %7B%0D%0A    
+, renameCallback) %7B%0D%0A    return new Promise((resolve, reject) =%3E %7B%0D%0A      // build options array%0D%0A      var options = %5B'-n' + format%5D;%0D%0A      options = options.concat(filePaths);%0D%0A      var jhead = spawn('jhead', options);%0D%0A      jhead.stdout.on('data', data =%3E console.log(data));%0D%0A      jhead.on('close', code =%3E resolve(code));%0D%0A    %7D
 %0D%0A  %7D%0D%0A%7D

add rename method, flatten tool options