#!/usr/bin/env node

// Licensed Materials - Property of IBM
// 5725-I43 (C) Copyright IBM Corp. 2015. All Rights Reserved.
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

var nopt = require('nopt');
var pluggington = require('pluggington');

var opts = nopt({
  extension: String
});

var command = opts.argv.remain[0];

if(command === 'ls') {
  var extensions = pluggington._getAllExtensions(process.cwd());

  if(opts.grep) {
    var extension = opts.extension;
    var matchingExtensions = extensions[extension];

    console.log(extension);
    if(matchingExtensions === undefined) {
      console.log("\tNo matching extensions!");
    } else {
      console.log(matchingExtensions);
    }
  } else {
    console.log(extensions);
  }
}
