Library for interactive command line interface?

Hi,

I'm looking for a way to control my program interactively through a command line interface. Similar to controlling linux through the shell or python through its scripting interface.

Is there a library that implements an interactive command-line interpreter? For those of you who have some experience with python: I'm looking for the C-counterpart of the python module cmd.
You mean like curses?
No, not like curses. I want to have a non-graphic user interface. For example, imagine a painting program. With a purely graphical user interface one could select the color of the pen via pressing a button. But I want a purely text-based interface, where you would set the color with a text command in an interactive command line like: "set pencolor red"
stdio ?
I'd like to have something much more high-level: define some commands and parameters, pass them to the magic command line interpreter and define some functions to call when the user types those commands. This is kinda like what the cmd module in python offers.
You could call Python from C++.
You could call Python from C++

You can do that? :S
You could call Python from C++.


Yes I could do that, but that would be overkill, if I just want to use it for the interactive command line.

If there's really no such library for c, I'm going to write one by myself.
Well, what you want is rather specific. You could also try reading the Python documentation. Maybe it says what that module is based on.

You can do that? :S
It's called "embedding". All you do is dynamically link to the interpreter and send code and/or data to it. It's also possible to call C/++ functions from Python. That's called "extending".
Well, what you want is rather specific. You could also try reading the Python documentation. Maybe it says what that module is based on.


Is is really that specific? Whenever you have a program that is controlled by a loop that waits for a command, then executes a command specific function, prints the results, and then waits for the next command a library like that one would be helpful. Usually when you write such programs, the commands are single characters. But sometimes more complex commands might be necessary.
I still think that stdio does that...
I still think that stdio does that...


I think with stdio you can only process input and output of streams (text streams for example). I will definitely need it to read in the command strings. But I think there's no way to use stdio for going the next steps, i.e. parsing the command strings, and automatically calling functions in my program corresponding to the commands
Command line input is a stream, parsing input isn't difficult.
Maybe I don't fully understand what you are trying to do, can you post an example in Python?
Topic archived. No new replies allowed.