mirror of
https://github.com/lhearachel/narc.git
synced 2025-06-18 13:35:32 -04:00
refactor(cli): Extract FAIL macro to command.h
This commit is contained in:
parent
f2583dbf6e
commit
a2e14a20b6
@ -18,6 +18,15 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// Standard failure macro. `fail` should be implemented for all commands
|
||||
// as an end-state where any potentially-allocated memory is freed and the
|
||||
// routine returns EXIT_FAILURE.
|
||||
#define FAIL(msgfmt, ...) \
|
||||
{ \
|
||||
fprintf(stderr, msgfmt, __VA_ARGS__); \
|
||||
goto fail; \
|
||||
}
|
||||
|
||||
struct command {
|
||||
const char *abbrev;
|
||||
const char *name;
|
||||
|
@ -19,15 +19,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// Standard failure macro. `fail` should be implemented for all commands
|
||||
// as an end-state where any potentially-allocated memory is freed and the
|
||||
// routine returns EXIT_FAILURE.
|
||||
#define FAIL(msgfmt, ...) \
|
||||
{ \
|
||||
fprintf(stderr, msgfmt, __VA_ARGS__); \
|
||||
goto fail; \
|
||||
}
|
||||
|
||||
bool match_either(const char *s, const char *a, const char *b);
|
||||
char *basename(const char *path);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "defs/narc.h"
|
||||
#include "defs/vfs.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "strbuild.h"
|
||||
#include "strutil.h"
|
||||
#include "strvec.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "defs/error.h"
|
||||
#include "defs/vfs.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "strutil.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "defs/fntb.h"
|
||||
#include "defs/vfs.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "strutil.h"
|
||||
|
||||
// clang-format off
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "api/files.h"
|
||||
#include "api/load.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "strutil.h"
|
||||
|
||||
// clang-format off
|
||||
|
Loading…
Reference in New Issue
Block a user