From: Siraaj Khandkar Date: Wed, 18 Nov 2020 11:13:27 +0000 (-0500) Subject: Re-format as a package X-Git-Tag: 0.3.5~11 X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=24c6a76b401882f7c263d07efdf73109fa483128;p=tt.git Re-format as a package --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..724bbe1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +compiled/ diff --git a/Makefile b/Makefile new file mode 100644 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 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 ")) +(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 new mode 100644 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) @@ -203,34 +200,34 @@ "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) @@ -245,5 +242,3 @@ (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)