Exemple #1
0
        }
    }
    private function optionsMenu()
    {
        print "Press 1: Convert To: can be csv,xml,json\nPress 2:OutputFile: path to output file\nPress 3: Input file format: Can be csv, xml, js\nPress 4 : path to Input file\nType convert: To convert..  ";
    }
}
spl_autoload_register(function ($i) {
    require_once $i . ".php";
}, true);
if (PHP_SAPI) {
    if (count($argv) < 2) {
        print "Usage : php Parser.php inputFile {ConvertTO:[xml|json|csv]} {InputFileFormat:[csv|js|xml]} {OutputFile:outfile}\nAny option inside {} this is optional.\nOption can be any order except first one has to be input file.\nkey : value this is how the options should be provided without curly braces. \nFirst is the key and second is the value.\nEnetring command line mode now!!";
        $p = new Parser();
        $p->interactivemode = true;
        $p->startIntercativeMode();
        exit;
    }
    $ifile = $argv[1];
    if (file_exists($ifile)) {
        array_splice($argv, 0, 2);
        $p = new Parser();
        $p->setInputFileAndParseIT($ifile);
        $p->createConfig(ConfigParser::parseConfigArray($argv));
        $p->parserHandler();
    } else {
        print "Input file {$ifile} doesn't exists.";
    }
} else {
    print "Only command line access is allowed.";
}