/**
 * Copyright © 2017 IBM Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <iostream>
#include <iterator>
#include <algorithm>
#include "argument.hpp"

namespace phosphor
{
namespace gpio
{

ArgumentParser::ArgumentParser(int argc, char** argv)
{
    int option = 0;
    while (-1 != (option = getopt_long(argc, argv, optionStr, options, NULL)))
    {
        if ((option == '?') || (option == 'h'))
        {
            usage(argv);
            exit(-1);
        }

        auto i = &options[0];
        while ((i->val != option) && (i->val != 0))
        {
            ++i;
        }

        if (i->val)
        {
            arguments[i->name] = (i->has_arg ? optarg : trueString);
        }
    }
}

const std::string& ArgumentParser::operator[](const std::string& opt)
{
    auto i = arguments.find(opt);
    if (i == arguments.end())
    {
        return emptyString;
    }
    else
    {
        return i->second;
    }
}

void ArgumentParser::usage(char** argv)
{
    std::cerr << "Usage: " << argv[0] << " [options]\n";
    std::cerr << "Options:\n";
    std::cerr << "    --help            Print this menu.\n";
    std::cerr << "    --gpio=<gpio>     The GPIO number.  Example: 1\n";
    std::cerr << "    --path=<path>     The path to the GPIO device."
                                        "  Example: /dev/gpiochip0\n";
    std::cerr << "    --delay=<delay>   The delay in ms in between a toggle."
                                        "  Example: 5\n";
    std::cerr << "    --action=<action> The action to do.\n";
    std::cerr << "                      Valid actions: low, high, low_high, "
                                        "high_low\n";
    std::cerr << std::flush;
}

const option ArgumentParser::options[] =
{
    { "action", required_argument, NULL, 'a' },
    { "gpio",   required_argument, NULL, 'g' },
    { "delay",  required_argument, NULL, 'd' },
    { "path",   required_argument, NULL, 'p' },
    { "help",   no_argument,       NULL, 'h' },
    { 0, 0, 0, 0},
};

const char* ArgumentParser::optionStr = "a:g:d:p:h?";

const std::string ArgumentParser::trueString = "true";
const std::string ArgumentParser::emptyString = "";

}
}
