mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-06-26 10:54:29 +02:00
Tasksh
- Added framework for readline support.
This commit is contained in:
parent
aacae1b1c6
commit
e559f49cd2
1 changed files with 27 additions and 4 deletions
31
src/main.cpp
31
src/main.cpp
|
@ -29,14 +29,37 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_READLINE
|
||||||
|
#include <readline/readline.h>
|
||||||
|
#include <readline/history.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static int commandLoop ()
|
static int commandLoop ()
|
||||||
{
|
{
|
||||||
// TODO Display prompt
|
// TODO Compose prompt.
|
||||||
// TODO Wait for input
|
std::string prompt = "task> ";
|
||||||
// TODO Dispatch command
|
|
||||||
|
|
||||||
return 0;
|
// Display prompt, get input.
|
||||||
|
char *line_read = readline (prompt.c_str ());
|
||||||
|
if (! line_read)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Save history.
|
||||||
|
if (*line_read)
|
||||||
|
add_history (line_read);
|
||||||
|
|
||||||
|
std::string command (line_read);
|
||||||
|
|
||||||
|
free (line_read);
|
||||||
|
|
||||||
|
// TODO Dispatch command
|
||||||
|
int status = 0;
|
||||||
|
if (command == "exit") status = 1;
|
||||||
|
// TODO diagnostics
|
||||||
|
// TODO help
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue