#include "config.h"

#include "global_options.hpp"

#include "config.hpp"

#include "gettext.hpp"

#include <string>
#include <vector>

#include <cassert>

using std::string;
using std::vector;

GlobalOptions::GlobalOptions()
{
  vector<string> dir_order_values;
  dir_order_values.push_back(gettext("directories first"));
  dir_order_values.push_back(gettext("by name"));

  vector<string> english_dir_order_values;
  english_dir_order_values.push_back("directories first");
  english_dir_order_values.push_back("by name");

  dir_order = new Option(false, gettext("sorting"), "sorting",
			 0, dir_order_values, english_dir_order_values);

  vector<string> cd_device_values;
  vector<string> english_cd_device_values;

  Config *conf = Config::get_instance();

  assert(conf->p_cdpath().size() == conf->p_cdname().size());

  std::list<std::pair<string, string> > cd_names = conf->p_cdname();

  for (std::list<std::pair<string, string> >::const_iterator iter = cd_names.begin(); 
       iter != cd_names.end(); ++iter) {
    cd_device_values.push_back(iter->second);
    english_cd_device_values.push_back(iter->second);
  }

  cd_device = new Option(false, gettext("cd device"), "cd device",
			 0, cd_device_values, english_cd_device_values);
}

GlobalOptions::~GlobalOptions()
{
  delete dir_order;
}

GlobalOptions* GlobalOptions::instance = 0;

GlobalOptions* GlobalOptions::get_instance() 
{
  if (instance == 0) {
    instance = new GlobalOptions;
  }
  return instance;
}
