summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-13 06:46:11 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-13 06:46:11 -0700
commitd34d09ef504ba2728821ce5b806bb59f22f378d7 (patch)
tree4179fc185523aaea0390ea7adecfbd070fd7e628 /txr.c
parent4ab891e4ba86a49cca1ae6988ee4a461a70285c3 (diff)
downloadtxr-d34d09ef504ba2728821ce5b806bb59f22f378d7.tar.gz
txr-d34d09ef504ba2728821ce5b806bb59f22f378d7.tar.bz2
txr-d34d09ef504ba2728821ce5b806bb59f22f378d7.zip
Go into listener if no arguments are given.
* txr.c (help): Document the behavior. (banner): New static function. (txr_main): If listener support compiled in, show the banner and go to REPL instead of showing the usage hint and bailing.
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/txr.c b/txr.c
index 1f8e0563..8b69d373 100644
--- a/txr.c
+++ b/txr.c
@@ -89,6 +89,10 @@ static void help(void)
"\n"
" ~a [ options ] query-file { data-file }*\n"
"\n"
+#if HAVE_TERMIOS
+"If no arguments are present, TXR will enter into interactive listener mode.\n"
+"\n"
+#endif
"The query-file or data-file arguments may be specified as -, in which case\n"
"standard input is used. All data-file arguments which begin with a !\n"
"character are treated as command pipes. Those which begin with a $\n"
@@ -162,11 +166,21 @@ static void help(void)
format(std_output, text, auto_str(version), prog_string, nao);
}
+#if HAVE_TERMIOS
+static void banner(void)
+{
+ format(std_output,
+ lit("This is the TXR Lisp interactive listener of TXR ~a.\n"
+ "Use the :quit command or type Ctrl-D on empty line to exit.\n"),
+ static_str(version), nao);
+}
+#else
static void hint(void)
{
format(std_error, lit("~a: incorrect arguments: try --help\n"),
prog_string, nao);
}
+#endif
static val remove_hash_bang_line(val spec)
{
@@ -405,8 +419,13 @@ int txr_main(int argc, char **argv)
setvbuf(stderr, 0, _IOLBF, 0);
if (argc <= 1) {
+#if HAVE_TERMIOS
+ banner();
+ goto repl;
+#else
hint();
return EXIT_FAILURE;
+#endif
}
while (*argv)
@@ -712,8 +731,13 @@ int txr_main(int argc, char **argv)
goto repl;
if (evaled)
return EXIT_SUCCESS;
+#if HAVE_TERMIOS
+ banner();
+ goto repl;
+#else
hint();
return EXIT_FAILURE;
+#endif
}
if (!equal(arg, lit("-"))) {