]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed a bug in pickfile and added debug tracing to the fetch command
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 30 Dec 2018 04:47:06 +0000 (23:47 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 30 Dec 2018 04:47:06 +0000 (23:47 -0500)
TODO.md
bin/pickfile [changed mode: 0644->0755]
inc/stdc.h
src/fetch.c

diff --git a/TODO.md b/TODO.md
index 6360bb94b0c8724a89c4b1f811a1fbd468af6acd..8ad4946490bf3e32b0d3c2dadce1c513c3fda283 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -3,13 +3,13 @@
 ## VERIFYING
 
 * paste of selection doesnt occur till next event
+* simultaneously write and read in tide sub commands
 
 ## STAGING
 
+* initialize pick query from argument
 * group by hostname or group env var in registrar
-* add debug Trace to fetch command
 * daemonize registrar and tide executables
-* simultaneously write and read in tide sub commands
 * Ctrl+D should not pass tag name as arg when executing tag commands
 * 'Get' tag with argument currently segfaults
 * registrar doesnt match open windows when new file created and is then opened for edit or line number
old mode 100644 (file)
new mode 100755 (executable)
index cd483ac..e04c77d
@@ -6,4 +6,4 @@ fi
 
 export PICKTITLE="Pick File ($PWD)"
 file="$(find $1 -not -path '*/\.*' -type f | sed 's|^\./||' | pick)"
-edit "$file"
+[ "" != "$file" ] && edit "$file"
index d42b1df5ddefaa12e40f8e4c0e03a0e20781622e..12f80a0d524a729d86d77b402c60e86843b82d5c 100644 (file)
@@ -99,7 +99,7 @@ static inline char* _getopt_(int* p_argc, char*** p_argv) {
     ) {                                                                       \
         int brk_; char argc_ , **argv_, *optarg_;                             \
         if (argv[0][1] == '-' && !argv[0][2]) {                               \
-            argv++, argc--; break;                                            \
+            (void)optarg_; argv++, argc--; break;                             \
         }                                                                     \
         for (brk_=0, argv[0]++, argv_=argv; argv[0][0] && !brk_; argv[0]++) { \
             if (argv_ != argv) break;                                         \
index 19e21cc09d6eeb1417f1bbb9ccc825d5244d816c..931e45d0522f5bbdec57ceb319fb99bcd75af75f 100644 (file)
@@ -8,6 +8,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+char* ARGV0;
+
 typedef struct {
     enum {
         COMPLETE=0, MATCHES, IS, ISSET, ISDIR, ISFILE,
@@ -177,17 +179,42 @@ void usage(char* pname) {
     exit(1);
 }
 
+char* type2str(int type) {
+    switch (type) {
+        case COMPLETE: return "COMPLETE";
+        case MATCHES:  return "MATCHES";
+        case IS:       return "IS";
+        case ISSET:    return "ISSET";
+        case ISDIR:    return "ISDIR";
+        case ISFILE:   return "ISFILE";
+        case SET:      return "SET";
+        case UNSET:    return "UNSET";
+        case FINDFILE: return "FINDFILE";
+        case EXEC:     return "EXEC";
+        case LAUNCH:   return "LAUNCH";
+    }
+    return "UNKNOWN";
+}
+
 int main(int argc, char** argv) {
-    if (argc != 2) usage(argv[0]);
-    setenv("data", argv[1], 1);
+    int debug = 0;
+    OPTBEGIN { case 'd': debug = 1; } OPTEND;
+
+    if (!argc) usage(ARGV0);
+    setenv("data", *argv, 1);
+
+    if (debug)
+        printf("Data: '%s'\n", *argv);
     for (unsigned int i = 0; i < nelem(BuiltinRules); i++) {
         Rule* rule = BuiltinRules[i];
+        if (debug)
+            printf("\nRuleset %d:\n", i);
         for (; rule->type != COMPLETE; rule++) {
-            //printf("%d '%s' '%s'\n", rule->type, rule->arg1, rule->arg2);
+            if (debug)
+                printf("    %s '%s' '%s'\n", type2str(rule->type), rule->arg1, rule->arg2);
             if (!apply_rule(rule))
                 break;
         }
-        //puts("");
         if (rule->type == COMPLETE)
             exit(0);
     }