Index: libcfa/src/parseargs.cfa
===================================================================
--- libcfa/src/parseargs.cfa	(revision cd021085d1b1fd9053f0376b7616c1aaaf7600d8)
+++ libcfa/src/parseargs.cfa	(revision d9265a22393bce8b8a41fc483ec05caf9784f79c)
@@ -29,15 +29,5 @@
 extern char ** cfa_args_envp;
 
-void printopt(FILE * out, int width, int max, char sn, const char * ln, const char * help) {
-	int hwidth = max - (11 + width);
-	if(hwidth <= 0) hwidth = max;
-
-	fprintf(out, "  -%c, --%-*s   %.*s\n", sn, width, ln, hwidth, help);
-	for() {
-		help += min(strlen(help), hwidth);
-		if('\0' == *help) break;
-		fprintf(out, "%*s%.*s\n", width + 11, "", hwidth, help);
-	}
-}
+static void usage(char * cmd, cfa_option options[], size_t opt_count, const char * usage, FILE * out)  __attribute__ ((noreturn));
 
 void parse_args( cfa_option options[], size_t opt_count, const char * usage, char ** & left ) {
@@ -45,4 +35,6 @@
 }
 
+//-----------------------------------------------------------------------------
+// getopt_long wrapping
 void parse_args(
 	int argc,
@@ -54,6 +46,4 @@
 ) {
 	struct option optarr[opt_count + 2];
-	int width = 0;
-	int max_width = 1_000_000;
 	{
 		int idx = 0;
@@ -70,7 +60,4 @@
 				}
 				idx++;
-
-				int w = strlen(options[i].long_name);
-				if(w > width) width = w;
 			}
 		}
@@ -107,5 +94,5 @@
 				out = stdout;
 			case '?':
-				goto USAGE;
+				usage(argv[0], options, opt_count, usage, out);
 			default:
 				for(i; opt_count) {
@@ -116,5 +103,5 @@
 
 						fprintf(out, "Argument '%s' for option %c could not be parsed\n\n", arg, (char)opt);
-						goto USAGE;
+						usage(argv[0], options, opt_count, usage, out);
 					}
 				}
@@ -123,6 +110,41 @@
 
 	}
-
-	USAGE:;
+}
+
+//-----------------------------------------------------------------------------
+// Print usage
+static void printopt(FILE * out, int width, int max, char sn, const char * ln, const char * help) {
+	int hwidth = max - (11 + width);
+	if(hwidth <= 0) hwidth = max;
+
+	fprintf(out, "  -%c, --%-*s   %.*s\n", sn, width, ln, hwidth, help);
+	for() {
+		help += min(strlen(help), hwidth);
+		if('\0' == *help) break;
+		fprintf(out, "%*s%.*s\n", width + 11, "", hwidth, help);
+	}
+}
+
+void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn)) {
+	usage(cfa_args_argv[0], options, opt_count, usage, error ? stderr : stdout);
+}
+
+void print_args_usage(int , char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn)) {
+	usage(argv[0], options, opt_count, usage, error ? stderr : stdout);
+}
+
+static void usage(char * cmd, cfa_option options[], size_t opt_count, const char * help, FILE * out) __attribute__((noreturn)) {
+	int width = 0;
+	{
+		int idx = 0;
+		for(i; opt_count) {
+			if(options[i].long_name) {
+				int w = strlen(options[i].long_name);
+				if(w > width) width = w;
+			}
+		}
+	}
+
+	int max_width = 1_000_000;
 	int outfd = fileno(out);
 	if(isatty(outfd)) {
@@ -133,5 +155,5 @@
 	}
 
-	fprintf(out, "Usage:\n  %s %s\n", argv[0], usage);
+	fprintf(out, "Usage:\n  %s %s\n", cmd, help);
 
 	for(i; opt_count) {
@@ -142,4 +164,6 @@
 }
 
+//-----------------------------------------------------------------------------
+// Typed argument parsing
 bool parse_yesno(const char * arg, bool & value ) {
 	if(strcmp(arg, "yes") == 0) {
Index: libcfa/src/parseargs.hfa
===================================================================
--- libcfa/src/parseargs.hfa	(revision cd021085d1b1fd9053f0376b7616c1aaaf7600d8)
+++ libcfa/src/parseargs.hfa	(revision d9265a22393bce8b8a41fc483ec05caf9784f79c)
@@ -34,4 +34,7 @@
 void parse_args( int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, char ** & left );
 
+void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
+void print_args_usage(int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
+
 bool parse_yesno   (const char *, bool & );
 bool parse_settrue (const char *, bool & );
