summary refs log tree commit diff
path: root/unscoop.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--unscoop.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/unscoop.c b/unscoop.c
index 6e7b362..eabb594 100644
--- a/unscoop.c
+++ b/unscoop.c
@@ -299,24 +299,33 @@ static void dedupEvents(sqlite3 *db) {
 }
 
 int main(int argc, char *argv[]) {
+	bool test = false;
 	char *path = NULL;
 	bool dedup = false;
 	const char *network = NULL;
 	const char *context = NULL;
 	const struct Format *format = &Formats[0];
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "DN:c:d:f:v"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "DN:c:d:f:nv"));) {
 		switch (opt) {
 			break; case 'D': dedup = true;
 			break; case 'N': network = optarg;
 			break; case 'c': context = optarg;
 			break; case 'd': path = optarg;
 			break; case 'f': format = formatParse(optarg);
+			break; case 'n': test = true;
 			break; case 'v': verbose = true;
 			break; default:  return EX_USAGE;
 		}
 	}
 
+	regex_t pathRegex = compile(format->pattern);
+	regex_t regex[format->len];
+	for (size_t i = 0; i < format->len; ++i) {
+		regex[i] = compile(format->matchers[i].pattern);
+	}
+	if (test) return EX_OK;
+
 	dbFind(path, SQLITE_OPEN_READWRITE);
 	if (dbVersion() != DatabaseVersion) {
 		errx(EX_CONFIG, "database out of date; migrate with litterbox -m");
@@ -328,12 +337,6 @@ int main(int argc, char *argv[]) {
 		return EX_OK;
 	}
 
-	regex_t pathRegex = compile(format->pattern);
-	regex_t regex[format->len];
-	for (size_t i = 0; i < format->len; ++i) {
-		regex[i] = compile(format->matchers[i].pattern);
-	}
-
 	sqlite3_stmt *insertContext = NULL;
 	const char *InsertContext = SQL(
 		INSERT OR IGNORE INTO contexts (network, name, query)
ms in input commandsJune McEnroe 2019-02-23Add C-n and C-p key bindings to switch windowsJune McEnroe 2019-02-23Change example command to join #ascii.town on freenodeJune McEnroe 2019-02-23Call def_prog_mode after termNoFlowJune McEnroe 2019-02-22Move IRC formatting reset to C-sJune McEnroe 2019-02-22Disable terminal flow controlJune McEnroe 2019-02-22Bind up and down arrows to scrollJune McEnroe 2019-02-22Remove topic TODOJune McEnroe 2019-02-22Add /znc commandJune McEnroe 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe 2019-02-21Replace "view" with "window"June McEnroe 2019-02-21Remove ROT13June McEnroe 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe