def command_gen(tool_installations, tool_executable, args=None, node_paths=None):
  """Generate a Command object with required tools installed and paths set up.

  :param list tool_installations: A list of functions to install required tools.  Those functions
    should take no parameter and return an installation path to be included in the runtime path.
  :param tool_executable: Name of the tool to be executed.
  :param list args: A list of arguments to be passed to the executable
  :param list node_paths: A list of path to node_modules.  node_modules/.bin will be appended
    to the run time path.
  :rtype: class: `Command`
  """
  node_module_bin_dir = 'node_modules/.bin'
  extra_paths = []
  for t in tool_installations:
    # Calling tool_installation[i]() triggers installation if tool is not installed
    extra_paths.append(t())
  if node_paths:
    for node_path in node_paths:
      if not node_path.endswith(node_module_bin_dir):
        node_path = os.path.join(node_path, node_module_bin_dir)
      extra_paths.append(node_path)
  return Command(executable=tool_executable, args=args, extra_paths=extra_paths)
Generate a Command object with required tools installed and paths set up.

  :param list tool_installations: A list of functions to install required tools.  Those functions
    should take no parameter and return an installation path to be included in the runtime path.
  :param tool_executable: Name of the tool to be executed.
  :param list args: A list of arguments to be passed to the executable
  :param list node_paths: A list of path to node_modules.  node_modules/.bin will be appended
    to the run time path.
  :rtype: class: `Command`