#include <string>
#ifdef HAVE_READLINE
- #include <readline/readline.h>
- #include <readline/history.h>
+#include <readline/readline.h>
+#include <readline/history.h>
#endif
////////////////////////////////////////////////////////////////////////////////
};
// Display prompt, get input
- #ifdef HAVE_READLINE
+#ifdef HAVE_READLINE
char * line_read = readline(prompt.c_str());
if (!line_read) {
std::cout << "\n";
response = std::string(line_read);
free(line_read);
}
- #else
+#else
std::cout << prompt;
std::getline(std::cin, response);
if (std::cin.eof() == 1) {
std::cout << "\n";
response = "<EOF>";
}
- #endif
+#endif
return response;
}
// Command line arguments
Sarge sarge;
- sarge.setArgument("a", "after", "Command to execute before leaving the shell", true);
- sarge.setArgument("b", "before", "Command to execute before entering the shell", true);
+ sarge.setArgument("a", "after",
+ "Command to execute before leaving the shell", true);
+ sarge.setArgument("b", "before",
+ "Command to execute before entering the shell", true);
sarge.setArgument("c", "command", "Command to convert to shell", true);
sarge.setArgument("h", "help", "Get help.", false);
sarge.setArgument("p", "prompt", "Define a custom prompt", true);
- sarge.setArgument("", "no-space", "Dont automatically add spaces after custom prompt and command", true);
+ sarge.setArgument("", "no-space",
+ "Dont automatically add spaces after custom prompt and command", true);
sarge.setDescription("Make a shell from any executable");
sarge.setUsage("gen-shell <options>");
- if (!sarge.parseArguments(argc, argv)) {
- std::cerr << "Couldn't parse arguments..." << std::endl;
- return 1;
- }
+ if (!sarge.parseArguments(argc, argv)) {
+ std::cerr << "Couldn't parse arguments..." << std::endl;
+ return 1;
+ }
- if (sarge.exists("help")) {
- sarge.printHelp();
+ if (sarge.exists("help")) {
+ sarge.printHelp();
return 0;
- }
+ }
bool space = true;
if (sarge.exists("no-space")) {
space = false;
- }
+ }
// Define input command
string arg_cmd;