Permalink
Browse files

test-graph: show usage string when no input is given on stdin

  • Loading branch information...
1 parent 1f384f3 commit ff63893e8091cf54a1c447bc9c0bebe977d1d278 @jonas committed Feb 22, 2013
Showing with 12 additions and 6 deletions.
  1. +12 −6 test-graph.c
View
@@ -9,17 +9,19 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * Example usage:
- *
- * # git log --pretty=raw --parents | ./test-graph
- * # git log --pretty=raw --parents | ./test-graph --ascii
*/
#include "tig.h"
#include "io.h"
#include "graph.h"
+#define USAGE \
+"test-graph [--ascii]\n" \
+"\n" \
+"Example usage:\n" \
+" # git log --pretty=raw --parents | ./test-graph\n" \
+" # git log --pretty=raw --parents | ./test-graph --ascii"
+
static void TIG_NORETURN
die(const char *err, ...)
{
@@ -28,7 +30,7 @@ die(const char *err, ...)
endwin();
va_start(args, err);
- fputs("tig: ", stderr);
+ fputs("test-graph: ", stderr);
vfprintf(stderr, err, args);
fputs("\n", stderr);
va_end(args);
@@ -58,6 +60,10 @@ main(int argc, const char *argv[])
if (argc > 1 && !strcmp(argv[1], "--ascii"))
graph_fn = graph_symbol_to_ascii;
+ if (isatty(STDIN_FILENO)) {
+ die(USAGE);
+ }
+
if (!io_open(&io, "%s", ""))
die("IO");

0 comments on commit ff63893

Please sign in to comment.