I'm working on a program that can be used directly from the command line with options and input files, or entirely interactively like a shell. For the initial execution I'm using GNU's Getopt to parse the command line options.
When being used on a file I'm using Flex and Bison. This simplifies the parsing greatly since the grammar is very simple, but I'm not entirely sure how I should tackle the shell aspect. I have used GNU's readline and history libraries before, when then I did this I relied solely on strtok and many comparisons with nested switch statements. It worked but it seemed kind of like a hack-job too me...
Is there a better way to approach this problem?
For the data input that the shell would allow I was thinking about piping it directly to a temp file and using Flex and Bison again, but for various parameters(like the command line options that Getopt is parsing for me now) is there a better way?
I was toying around with the idea of trying to recycle my getopt code, since its flexible to capture everything and if its not a option I could assume its data and pipe it out. But I'd love a 2nd opinion.
Thanks