Skip to content

Commit 32d032f

Browse files
Roguelazerben-healthforge
authored andcommitted
add a help
1 parent b41f52f commit 32d032f

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

configure.ac

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# Process this file with autoconf to produce a configure script.
33

44
AC_PREREQ([2.69])
5-
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
6-
AC_CONFIG_SRCDIR([json_parser.y])
5+
AC_INIT([jsonval], [0.0.2], [https://github.com/dangerousben/jsonval/issues])
76
AC_CONFIG_HEADERS([config.h])
87

98
# Checks for programs.

main.c

+19-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <stdio.h>
2121
#include <stdlib.h>
2222
#include <getopt.h>
23+
#include "config.h"
2324
#include "json_parser.h"
2425
#include "json_scanner.h"
2526

@@ -28,13 +29,30 @@ unsigned char parse_and_report(const char *);
2829

2930
int xml_output = 0;
3031

32+
void usage() {
33+
printf("Usage: %s [options] [/path/to/file]\n", PACKAGE);
34+
printf("\t\t(if file is not specified or -, read from stdin)\n");
35+
printf("\nOPTIONS:\n");
36+
printf("-x\t\tOutput in jslint-esque XML\n");
37+
printf("-h\t\tShow this help\n");
38+
printf("-v\t\tShow version number\n");
39+
exit(0);
40+
}
41+
3142
int main(int argc, char *argv[])
3243
{
3344
unsigned char err = 0;
3445
int c;
3546

36-
while((c = getopt(argc, argv, "x")) != -1) {
47+
while((c = getopt(argc, argv, "hvx")) != -1) {
3748
switch(c) {
49+
case 'h':
50+
usage();
51+
break;
52+
case 'v':
53+
printf("%s %s\n", PACKAGE, PACKAGE_VERSION);
54+
exit(0);
55+
break;
3856
case 'x':
3957
xml_output = 1;
4058
break;

0 commit comments

Comments
 (0)