radk.scm
1 | ;;; Nani Project website |
2 | ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> |
3 | ;;; |
4 | ;;; This file is part of the Nani Project website. |
5 | ;;; |
6 | ;;; The Nani Project website is free software; you can redistribute it and/or modify it |
7 | ;;; under the terms of the GNU Affero General Public License as published by |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
9 | ;;; your option) any later version. |
10 | ;;; |
11 | ;;; The Nani Project website is distributed in the hope that it will be useful, but |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | ;;; GNU Affero General Public License for more details. |
15 | ;;; |
16 | ;;; You should have received a copy of the GNU Affero General Public License |
17 | ;;; along with the Nani Project website. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | (use-modules (nani radk)) |
20 | (use-modules (ice-9 match)) |
21 | (use-modules (ice-9 binary-ports)) |
22 | |
23 | (match (command-line) |
24 | ((_ cmd radk-file kanjidic-file output) |
25 | (cond |
26 | ((equal? cmd "build") |
27 | (let* ((radk (parse-radk radk-file)) |
28 | (rad-stroke (get-rad-stroke radk)) |
29 | (rad-kanji (get-rad-kanji radk)) |
30 | (kanji-stroke (get-kanji-stroke kanjidic-file))) |
31 | (call-with-output-file output |
32 | (lambda (port) |
33 | (put-bytevector port |
34 | (serialize-radk rad-kanji rad-stroke kanji-stroke)))))) |
35 | (else (format #t "Unknown cmd ~a.~%" cmd))))) |
36 |