import getopt;
import std.stdio;
void main(char[][] args) {
    args = args[1..args.length];
    getopt_t[] usedoptions;

    /*foreach(char[] argv;args) 
    {
        writefln("File: ", argv);
    }
   */
    char[] shortoptions = "hvtn?";
    char[][5] longoptions;
    int iLen=0;
    int idxop = -1;
    longoptions[][++idxop] = "help";
    longoptions[][++idxop] = "version";
		longoptions[][++idxop] = "traditional";
		longoptions[][++idxop] = "next-generation";

    try
    {
        GetOpt getopt  =new  GetOpt();
        usedoptions=getopt.getopt(args, shortoptions, longoptions);
    } catch(GetOptException e)
    {
        writefln("Error in passed options: ", e.msg);
        return 1;
    }

    foreach(getopt_t item; usedoptions){

        if (item.option == "-h" || item.option == "--help" || item.option == "-?")
        {
            writefln("``Hello World!'' is a greeting program which wrote by jinheking.\n",

                        "\n",

                        "Usage: hello [OPTIONS]\n",

                        "       -h, --help             display this message then exit.\n",
                        
                        "       -?,                    display this message then exit.\n",

                        "       -v, --version          display version information then exit.\n",

                        "\n",

                        "       -t, --traditional      output a greeting message with traditional format.\n",

                        "       -n, --next-generation  output a greeting message with next-generation format.\n",

                        "\n",

                        "Report bugs to <jinheking@gmail.com>\n");
        }
        else if (item.option == "-v" || item.option == "--version"){
            char[] output = item.value;
            writefln("Hello World - jinheking's hello world. 0.01 version\n");
           
        }
        else if (item.option == "-t" || item.option == "--traditional"){
            char[] output = item.value;
            writefln("Hello, World\n");
        }
        else if (item.option == "-n" || item.option == "--next-generation"){
            char[] output = item.value;
            writefln("+---------------+\n",

                        "| Hello, world! |\n",

                        "+---------------+\n");
        }
        iLen++;
    }
    
    if(iLen==0){ 
			writefln("Mr. Watson. Come Here. I need you.");
			} 		
}