Compare commits
No commits in common. "mistress" and "1.0.1" have entirely different histories.
6 changed files with 45 additions and 25 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
/makefile.csm
|
|
||||||
/rain
|
|
||||||
19
Makefile
Normal file
19
Makefile
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
CSM := csm
|
||||||
|
PREFIX := /usr/local
|
||||||
|
INSTALL := install
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: Makefile.csm
|
||||||
|
$(MAKE) -f Makefile.csm
|
||||||
|
|
||||||
|
Makefile.csm:
|
||||||
|
$(CSM) -makefile Makefile.csm
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: Makefile.csm
|
||||||
|
$(MAKE) -f Makefile.csm clean
|
||||||
|
rm -f Makefile.csm rain
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install:
|
||||||
|
$(INSTALL) -sDm755 rain $(DESTDIR)$(PREFIX)/bin/rain
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
- [CHICKEN Scheme](https://call-cc.org) 5 or 6;
|
- [CHICKEN Scheme](https://call-cc.org) 5 or 6;
|
||||||
- A few CHICKEN extensions, installable using `chicken-install -s format html-parser openssl http-client matchable`.
|
- A few CHICKEN extensions, installable using `chicken-install -s format html-parser openssl http-client matchable srfi-18`.
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
|
|
|
||||||
18
makefile
18
makefile
|
|
@ -1,18 +0,0 @@
|
||||||
CSM := csm
|
|
||||||
PREFIX := /usr/local
|
|
||||||
INSTALL := install
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all: makefile.csm
|
|
||||||
$(MAKE) -f makefile.csm
|
|
||||||
|
|
||||||
makefile.csm:
|
|
||||||
$(CSM) -makefile makefile.csm
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
git clean -fdx
|
|
||||||
|
|
||||||
.PHONY: install
|
|
||||||
install:
|
|
||||||
$(INSTALL) -sDm755 rain $(DESTDIR)$(PREFIX)/bin/rain
|
|
||||||
26
rain.scm
26
rain.scm
|
|
@ -1,3 +1,5 @@
|
||||||
|
(define parallel 1)
|
||||||
|
|
||||||
(define (find-comic-image index)
|
(define (find-comic-image index)
|
||||||
(call-with-current-continuation
|
(call-with-current-continuation
|
||||||
(lambda (k)
|
(lambda (k)
|
||||||
|
|
@ -18,20 +20,38 @@
|
||||||
(format (current-error-port) "* downloaded comic image ~a~%" index))
|
(format (current-error-port) "* downloaded comic image ~a~%" index))
|
||||||
|
|
||||||
(define (download-all indices)
|
(define (download-all indices)
|
||||||
(for-each download-comic-image indices))
|
(format (current-error-port) "* using ~a threads~%" parallel)
|
||||||
|
(for-each download-batch (chop indices parallel)))
|
||||||
|
|
||||||
|
(define (download-batch batch)
|
||||||
|
(let ((threads (map (lambda (index)
|
||||||
|
(make-thread
|
||||||
|
(lambda ()
|
||||||
|
(download-comic-image index))))
|
||||||
|
batch)))
|
||||||
|
(for-each thread-start! threads)
|
||||||
|
(for-each thread-join! threads)))
|
||||||
|
|
||||||
(define (usage)
|
(define (usage)
|
||||||
(format (current-error-port) "usage: ~a [OPTION ...] INDEX ...~%" (program-name))
|
(format (current-error-port) "usage: ~a [OPTION ...] INDEX ...~%" (program-name))
|
||||||
(format (current-error-port) "options:~%")
|
(format (current-error-port) "options:~%")
|
||||||
(format (current-error-port) " -h|-help display this help message~%")
|
(format (current-error-port) " -h|-help display this help message~%")
|
||||||
(format (current-error-port) " -v|-version display version information~%"))
|
(format (current-error-port) " -v|-version display version information~%")
|
||||||
|
(format (current-error-port) " -j|-parallel N download N images in parallel~%"))
|
||||||
|
|
||||||
(define parse-command-line
|
(define parse-command-line
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(((or "-h" "-help") . _)
|
(((or "-h" "-help") . _)
|
||||||
(usage))
|
(usage))
|
||||||
(((or "-v" "-version") . _)
|
(((or "-v" "-version") . _)
|
||||||
(format (current-error-port) "rain.scm 1.0.1~%" (program-name)))
|
(format (current-error-port) "rain.scm 1.0.0~%" (program-name)))
|
||||||
|
(((or "-j" "-parallel") n . rest)
|
||||||
|
(let ((nn (string->number n)))
|
||||||
|
(unless nn
|
||||||
|
(usage)
|
||||||
|
(exit 1))
|
||||||
|
(set! parallel nn)
|
||||||
|
(parse-command-line rest)))
|
||||||
(()
|
(()
|
||||||
(usage))
|
(usage))
|
||||||
(indices
|
(indices
|
||||||
|
|
|
||||||
3
rain.sld
3
rain.sld
|
|
@ -14,6 +14,7 @@ exec csi -s "$0" "$@"
|
||||||
(html-parser)
|
(html-parser)
|
||||||
(openssl) ; has to be before http-client
|
(openssl) ; has to be before http-client
|
||||||
(http-client)
|
(http-client)
|
||||||
(matchable))
|
(matchable)
|
||||||
|
(srfi-18))
|
||||||
(include "rain.scm")
|
(include "rain.scm")
|
||||||
(begin (main (command-line-arguments))))
|
(begin (main (command-line-arguments))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue