finder.js
function startSearch() {
  iface.question('Enter search: ', function (query) {
    // Get the results of our query
    var matches = fileFinder.query(query),
        len = matches.length;

    // If no results were found
    if (len === 0) {
      console.log('No results found for: ' + query);
      startSearch();
    } else if (len === 1) {
      var item = matches[0];
    // If there is one, skip to go
      console.log('Opening: ' + item);
      fileFinder.open(item);

      // Begin the search again
      startSearch();
    } else {
    // Otherwise, list options
      console.log('');
      console.log('----------------');
      console.log('Search Results');
      console.log('----------------');
      for (i = 0; i < len; i++) {
        console.log(i + ': ' + matches[i]);
      }

      // Ask for a number
      iface.question('Which item would you like to open? ', function (numStr) {
        var num = +numStr,
            item;

        // If the number is not NaN and we were not given an empty string
        if (num === num && numStr !== '') {
          // and if it is in our result set
          if (num >= 0 && num < len) {
            // Open it
            item = matches[num];
            console.log('Opening: ' + item);
            fileFinder.open(item);
          }
        } else {
        // Otherwise, if there was a word in there so we are assuming it was 'rescan'
          // Rescan
          console.log('Rescanning...');
          fileFinder.scan();
        }

        // Begin the search again
        startSearch();
      });
    }
  });
}
function startSearch() {
  iface.question('Enter search: ', function (query) {
    // Get the results of our query
    var matches = fileFinder.query(query),
        len = matches.length;

    // If no results were found
    if (len === 0) {
      console.log('No results found for: ' + query);
      startSearch();
    } else if (len === 1) {
      var item = matches[0];
    // If there is one, skip to go
      console.log('Opening: ' + item);
      fileFinder.open(item);

      // Begin the search again
      startSearch();
    } else {
    // Otherwise, list options
      console.log('');
      console.log('----------------');
      console.log('Search Results');
      console.log('----------------');
      for (i = 0; i < len; i++) {
        console.log(i + ': ' + matches[i]);
      }

      // Ask for a number
      iface.question('Which item would you like to open? ', function (numStr) {
        var num = +numStr,
            item;

        // If the number is not NaN and we were not given an empty string
        if (num === num && numStr !== '') {
          // and if it is in our result set
          if (num >= 0 && num < len) {
            // Open it
            item = matches[num];
            console.log('Opening: ' + item);
            fileFinder.open(item);
          }
        } else {
        // Otherwise, if there was a word in there so we are assuming it was 'rescan'
          // Rescan
          console.log('Rescanning...');
          fileFinder.scan();
        }

        // Begin the search again
        startSearch();
      });
    }
  });
}
function startSearch ( ) { iface . question ( 'Enter search: ' , function ( query ) { // Get the results of our query
 var matches = fileFinder . query ( query ) , len = matches . length ; // If no results were found
 if ( len === 0 ) { console . log ( 'No results found for: ' + query ) ; startSearch ( ) ; } else if ( len === 1 ) { var item = matches [ 0 ] ; // If there is one, skip to go
 console . log ( 'Opening: ' + item ) ; fileFinder . open ( item ) ; // Begin the search again
 startSearch ( ) ; } else { // Otherwise, list options
 console . log ( '' ) ; console . log ( '----------------' ) ; console . log ( 'Search Results' ) ; console . log ( '----------------' ) ; for ( i = 0 ; i < len ; i ++ ) { console . log ( i + ': ' + matches [ i ] ) ; } // Ask for a number
 iface . question ( 'Which item would you like to open? ' , function ( numStr ) { var num = + numStr , item ; // If the number is not NaN and we were not given an empty string
 if ( num === num && numStr !== '' ) { // and if it is in our result set
 if ( num >= 0 && num < len ) { // Open it
 item = matches [ num ] ; console . log ( 'Opening: ' + item ) ; fileFinder . open ( item ) ; } } else { // Otherwise, if there was a word in there so we are assuming it was 'rescan'
 // Rescan
 console . log ( 'Rescanning...' ) ; fileFinder . scan ( ) ; } // Begin the search again
 startSearch ( ) ; } ) ; } } ) ; }
Set up startSearch for calling later
Set up startSearch for calling later