function retrieve_args() { $opt = new Getopt([(new Option('h', 'help'))->setDescription('Prints this help'), (new Option('v', 'verbose'))->setDescription('Verbose output'), (new Option('f', 'file-title'))->setDescription('Use file name for title tag'), (new Option('x', 'sort-lex'))->setDescription('Sort files lexicographically'), (new Option('t', 'tree-dst'))->setDescription('Retain the tree structure of the source album at destination'), (new Option('p', 'drop-dst'))->setDescription('Do not create destination directory'), (new Option('r', 'reverse'))->setDescription('Copy files in reverse order (last file first)'), (new Option('e', 'file-type', Getopt::REQUIRED_ARGUMENT))->setDescription('Accept only audio files of the specified type'), (new Option('u', 'unified-name', Getopt::REQUIRED_ARGUMENT))->setDescription('Base name for everything but the "Artist" tag'), (new Option('b', 'album-num', Getopt::REQUIRED_ARGUMENT))->setDescription('Album number'), (new Option('a', 'artist-tag', Getopt::REQUIRED_ARGUMENT))->setDescription('"Artist" tag'), (new Option('g', 'album-tag', Getopt::REQUIRED_ARGUMENT))->setDescription('"Album" tag')]); $opt->parse(); if ($opt->getOption('help')) { print $opt->getHelpText(); exit(2); } if (count($opt->getOperands()) !== 2) { print "Command line syntax: <src> and <dst> operands required.\n" . $opt->getHelpText(); exit(2); } if (!is_dir($opt->getOperand(0))) { print "Source directory \"{$opt->getOperand(0)}\" is not there.\n"; exit(2); } if (!is_dir($opt->getOperand(1))) { print "Destination path \"{$opt->getOperand(1)}\" is not there.\n"; exit(2); } return $opt; }