~brenns10/sc-argparse

1e71fc66f78382f38942017af3fc9f274e5e69ce — Stephen Brennan 4 years ago 4612afd
Run pre-commit on all files
2 files changed, 14 insertions(+), 13 deletions(-)

M include/sc-argparse.h
M src/sc-argparse.c
M include/sc-argparse.h => include/sc-argparse.h +13 -12
@@ 129,38 129,39 @@ int sc_argparse(struct sc_arg argspec[], int argc, char **argv);
 * Define a string argument with a default value. It is not required to appear
 * on the command line.
 */
#define SC_ARG_DEF_STRING(flag, name, default_, help) \
	((struct sc_arg){flag, false, SC_ARG_TYPE_STRING, name, help, default_})
#define SC_ARG_DEF_STRING(flag, name, default_, help)                          \
	((struct sc_arg){ flag, false, SC_ARG_TYPE_STRING, name, help,         \
	                  default_ })
/**
 * Define a string argument without a default value. It is required to appear on
 * the command line.
 */
#define SC_ARG_STRING(flag, name, help) \
	((struct sc_arg){flag, true, SC_ARG_TYPE_STRING, name, help})
#define SC_ARG_STRING(flag, name, help)                                        \
	((struct sc_arg){ flag, true, SC_ARG_TYPE_STRING, name, help })

/**
 * Define an integer argument with a default value. It is not required to appear
 * on the command line.
 */
#define SC_ARG_DEF_INT(flag, name, default_, help) \
	((struct sc_arg){flag, false, SC_ARG_TYPE_INT, name, help, NULL, default_})
#define SC_ARG_DEF_INT(flag, name, default_, help)                             \
	((struct sc_arg){ flag, false, SC_ARG_TYPE_INT, name, help, NULL,      \
	                  default_ })
/**
 * Define an integer argument without a default value. It is required to appear
 * on the command line.
 */
#define SC_ARG_INT(flag, name, help) \
	((struct sc_arg){flag, true, SC_ARG_TYPE_INT, name, help})
#define SC_ARG_INT(flag, name, help)                                           \
	((struct sc_arg){ flag, true, SC_ARG_TYPE_INT, name, help })

/**
 * Define an count argument. It is not required to appear on the command line.
 */
#define SC_ARG_COUNT(flag, name, help) \
	((struct sc_arg){flag, false, SC_ARG_TYPE_COUNT, name, help})
#define SC_ARG_COUNT(flag, name, help)                                         \
	((struct sc_arg){ flag, false, SC_ARG_TYPE_COUNT, name, help })

/**
 * Signals the end of the argument specification.
 */
#define SC_ARG_END() \
	((struct sc_arg){0})
#define SC_ARG_END() ((struct sc_arg){ 0 })

#endif

M src/sc-argparse.c => src/sc-argparse.c +1 -1
@@ 2,8 2,8 @@
 * sc-argparse.c: simple argument parsing library
 */

#include <string.h>
#include <stdlib.h>
#include <string.h>

#include "sc-argparse.h"