getopt cmdline parser, separated algorithm functions