Re-format as a package
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 18 Nov 2020 11:13:27 +0000 (06:13 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 18 Nov 2020 11:39:22 +0000 (06:39 -0500)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
info.rkt [new file with mode: 0644]
tt.rkt [moved from tt with 85% similarity, mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..724bbe1
--- /dev/null
@@ -0,0 +1 @@
+compiled/
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..bced2e6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+.PHONY: install
+install:
+       raco pkg install
+
+.PHONY: remove
+remove:
+       raco pkg remove tt
+
+.PHONY: clean
+clean:
+       rm -rf compiled
diff --git a/info.rkt b/info.rkt
new file mode 100644 (file)
index 0000000..22b55b8
--- /dev/null
+++ b/info.rkt
@@ -0,0 +1,17 @@
+; vim: filetype=racket
+#lang info
+
+(define collection
+  "tt")
+(define pkg-desc
+  "twtxt client")
+(define version
+  "0.3.4")
+(define pkg-authors
+  '("Siraaj Khandkar <siraaj@khandkar.net>"))
+(define deps
+  '("base" "http-client" "rfc3339-old"))
+(define racket-launcher-names
+  '("tt"))
+(define racket-launcher-libraries
+  '("tt.rkt"))
diff --git a/tt b/tt.rkt
old mode 100755 (executable)
new mode 100644 (file)
similarity index 85%
rename from tt
rename to tt.rkt
index 840a8e5..b11364f
--- a/tt
+++ b/tt.rkt
@@ -1,6 +1,3 @@
-#! /usr/bin/env racket
-; vim: filetype=racket
-
 ; TODO optional text wrap
 ; TODO write
 ; TODO caching (use cache by default, unless explicitly asked for update)
     "https://raw.githubusercontent.com/mdom/we-are-twtxt/master/we-are-twtxt.txt")
   (str->feeds (uri-fetch uri)))
 
-(define (setup-logging)
-  (define logger (make-logger #f #f 'debug #f))
-  (define log-chan (make-log-receiver logger 'debug))
-  (void (thread (λ ()
-                   [date-display-format 'iso-8601]
-                   [let loop ()
-                     (define data  (sync log-chan))
-                     (define level (vector-ref data 0))
-                     (define msg   (vector-ref data 1))
-                     (define ts    (date->string (current-date) #t))
-                     (eprintf "~a [~a] ~a~n" ts level msg)
-                     (loop)])))
-  (current-logger logger))
-
-(define (main)
-  (define user-agent
-    (let*
-      ([prog-name      "tt"]
-       [prog-version   "0.3.4"]
-       [prog-uri       "https://github.com/xandkar/tt"]
-       [user-feed-file (expand-user-path "~/twtxt-me.txt")]
-       [user
-         (if (file-exists? user-feed-file)
-           (let ([user (first (file->feeds user-feed-file))])
-             (format "+~a; @~a" (feed-uri user) (feed-nick user)))
-           (format "+~a" prog-uri))]
-       )
-      (format "~a/~a (~a)" prog-name prog-version user)))
+(define user-agent
+  (let*
+    ([prog-name      "tt"]
+     [prog-version   "0.3.4"]
+     [prog-uri       "https://github.com/xandkar/tt"]
+     [user-feed-file (expand-user-path "~/twtxt-me.txt")]
+     [user
+       (if (file-exists? user-feed-file)
+         (let ([user (first (file->feeds user-feed-file))])
+           (format "+~a; @~a" (feed-uri user) (feed-nick user)))
+         (format "+~a" prog-uri))]
+     )
+    (format "~a/~a (~a)" prog-name prog-version user)))
+
+(module+ main
+  (define (setup-logging)
+    (define logger (make-logger #f #f 'debug #f))
+    (define log-chan (make-log-receiver logger 'debug))
+    (void (thread (λ ()
+                     [date-display-format 'iso-8601]
+                     [let loop ()
+                       (define data  (sync log-chan))
+                       (define level (vector-ref data 0))
+                       (define msg   (vector-ref data 1))
+                       (define ts    (date->string (current-date) #t))
+                       (eprintf "~a [~a] ~a~n" ts level msg)
+                       (loop)])))
+    (current-logger logger))
 
   (setup-logging)
   (current-http-response-auto #f)
   (define out-format 'multi-line)
   (define num_workers 15) ; 15 was fastest out of the tried 1, 5, 10, 15 and 20.
   (timeline-print out-format (timeline num_workers feeds)))
-
-(main)
This page took 0.033394 seconds and 4 git commands to generate.