- check for arg count before printing the header so the header doesn't appear when displaying usage

Fri, 02 May 2014 21:42:11 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Fri, 02 May 2014 21:42:11 +0300
changeset 127
ed4289183de6
parent 126
c5858c0cd476
child 128
186ebeea2a85

- check for arg count before printing the header so the header doesn't appear when displaying usage

src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/main.cpp	Fri May 02 21:38:19 2014 +0300
+++ b/src/main.cpp	Fri May 02 21:42:11 2014 +0300
@@ -59,6 +59,13 @@
 			exit (0);
 		}
 
+		if (argc < 2)
+		{
+			fprintf (stderr, "usage: %s <infile> [outfile] # compiles botscript\n", argv[0]);
+			fprintf (stderr, "       %s -l                 # lists commands\n", argv[0]);
+			exit (1);
+		}
+
 		// Print header
 		String header;
 		String headerline;
@@ -89,13 +96,6 @@
 		headerline += '-';
 		print ("%2\n\n%1\n\n%2\n\n", header, headerline);
 
-		if (argc < 2)
-		{
-			fprintf (stderr, "usage: %s <infile> [outfile] # compiles botscript\n", argv[0]);
-			fprintf (stderr, "       %s -l                 # lists commands\n", argv[0]);
-			exit (1);
-		}
-
 		String outfile;
 
 		if (argc < 3)

mercurial