mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-06-26 10:54:29 +02:00
Portability
- Although libreadline will be required, for now this needs to be buildable and testable on machines without libreadline.
This commit is contained in:
parent
d1a9228b41
commit
712ea861de
2 changed files with 18 additions and 2 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -35,6 +35,10 @@
|
|||
#include <readline/history.h>
|
||||
#endif
|
||||
|
||||
// TODO These conflict with tw commands. This needs to be resolved.
|
||||
// Perhaps an escape, such as '-- help' could invoke local help, or using
|
||||
// a 'task' prefix could disambiguate.
|
||||
|
||||
// tasksh commands.
|
||||
int cmdHelp ();
|
||||
int cmdDiagnostics ();
|
||||
|
@ -49,6 +53,7 @@ static int commandLoop ()
|
|||
std::string prompt = composePrompt ();
|
||||
|
||||
// Display prompt, get input.
|
||||
#ifdef HAVE_READLINE
|
||||
char *line_read = readline (prompt.c_str ());
|
||||
if (! line_read)
|
||||
{
|
||||
|
@ -62,6 +67,13 @@ static int commandLoop ()
|
|||
|
||||
std::string command (line_read);
|
||||
free (line_read);
|
||||
#else
|
||||
std::cout << prompt;
|
||||
std::string command;
|
||||
std::getline (std::cin, command);
|
||||
if (command.find ('\n') == std::string::npos)
|
||||
std::cout << "\n";
|
||||
#endif
|
||||
|
||||
// Dispatch command
|
||||
int status = 0;
|
||||
|
@ -70,8 +82,6 @@ static int commandLoop ()
|
|||
else if (closeEnough ("help", command, 3)) status = cmdHelp ();
|
||||
else if (closeEnough ("diagnostics", command, 3)) status = cmdDiagnostics ();
|
||||
|
||||
// TODO help
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue