diff options
| -rw-r--r-- | .dir-locals.el | 88 | ||||
| -rw-r--r-- | Makefile.am | 87 | ||||
| -rw-r--r-- | README | 2 | ||||
| -rwxr-xr-x | bootstrap | 5 | ||||
| -rwxr-xr-x | build-aux/pre-inst-env.in | 28 | ||||
| -rw-r--r-- | configure.ac | 55 | ||||
| -rw-r--r-- | feed.scm | 3 | ||||
| -rw-r--r-- | feed/scripts/rss.scm | 107 | ||||
| -rw-r--r-- | feed/ui.scm | 118 | ||||
| -rw-r--r-- | guix.scm | 129 | ||||
| -rwxr-xr-x | scripts/feed.in | 27 | ||||
| -rw-r--r-- | tests/rss.scm | 40 |
12 files changed, 689 insertions, 0 deletions
diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..cf0cbf5 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,88 @@ +;; Per-directory local variables for GNU Emacs 23 and later. + +((nil + . ((fill-column . 78) + (tab-width . 8) + (sentence-end-double-space . t))) + (c-mode . ((c-file-style . "gnu"))) + (scheme-mode + . + ((indent-tabs-mode . nil) + (eval . (put 'eval-when 'scheme-indent-function 1)) + (eval . (put 'call-with-prompt 'scheme-indent-function 1)) + (eval . (put 'test-assert 'scheme-indent-function 1)) + (eval . (put 'test-assertm 'scheme-indent-function 1)) + (eval . (put 'test-equalm 'scheme-indent-function 1)) + (eval . (put 'test-equal 'scheme-indent-function 1)) + (eval . (put 'test-eq 'scheme-indent-function 1)) + (eval . (put 'call-with-input-string 'scheme-indent-function 1)) + (eval . (put 'guard 'scheme-indent-function 1)) + (eval . (put 'lambda* 'scheme-indent-function 1)) + (eval . (put 'substitute* 'scheme-indent-function 1)) + (eval . (put 'match-record 'scheme-indent-function 2)) + + ;; 'modify-phases' and its keywords. + (eval . (put 'modify-phases 'scheme-indent-function 1)) + (eval . (put 'replace 'scheme-indent-function 1)) + (eval . (put 'add-before 'scheme-indent-function 2)) + (eval . (put 'add-after 'scheme-indent-function 2)) + + (eval . (put 'modify-services 'scheme-indent-function 1)) + (eval . (put 'with-directory-excursion 'scheme-indent-function 1)) + (eval . (put 'package 'scheme-indent-function 0)) + (eval . (put 'origin 'scheme-indent-function 0)) + (eval . (put 'build-system 'scheme-indent-function 0)) + (eval . (put 'bag 'scheme-indent-function 0)) + (eval . (put 'graft 'scheme-indent-function 0)) + (eval . (put 'operating-system 'scheme-indent-function 0)) + (eval . (put 'file-system 'scheme-indent-function 0)) + (eval . (put 'manifest-entry 'scheme-indent-function 0)) + (eval . (put 'manifest-pattern 'scheme-indent-function 0)) + (eval . (put 'substitute-keyword-arguments 'scheme-indent-function 1)) + (eval . (put 'with-store 'scheme-indent-function 1)) + (eval . (put 'with-error-handling 'scheme-indent-function 0)) + (eval . (put 'with-mutex 'scheme-indent-function 1)) + (eval . (put 'with-atomic-file-output 'scheme-indent-function 1)) + (eval . (put 'call-with-compressed-output-port 'scheme-indent-function 2)) + (eval . (put 'call-with-decompressed-port 'scheme-indent-function 2)) + (eval . (put 'call-with-gzip-input-port 'scheme-indent-function 1)) + (eval . (put 'call-with-gzip-output-port 'scheme-indent-function 1)) + (eval . (put 'signature-case 'scheme-indent-function 1)) + (eval . (put 'emacs-batch-eval 'scheme-indent-function 0)) + (eval . (put 'emacs-batch-edit-file 'scheme-indent-function 1)) + (eval . (put 'emacs-substitute-sexps 'scheme-indent-function 1)) + (eval . (put 'emacs-substitute-variables 'scheme-indent-function 1)) + (eval . (put 'with-derivation-narinfo 'scheme-indent-function 1)) + (eval . (put 'with-derivation-substitute 'scheme-indent-function 2)) + + (eval . (put 'mlambda 'scheme-indent-function 1)) + (eval . (put 'mlambdaq 'scheme-indent-function 1)) + (eval . (put 'syntax-parameterize 'scheme-indent-function 1)) + (eval . (put 'with-monad 'scheme-indent-function 1)) + (eval . (put 'mbegin 'scheme-indent-function 1)) + (eval . (put 'mwhen 'scheme-indent-function 1)) + (eval . (put 'munless 'scheme-indent-function 1)) + (eval . (put 'mlet* 'scheme-indent-function 2)) + (eval . (put 'mlet 'scheme-indent-function 2)) + (eval . (put 'run-with-store 'scheme-indent-function 1)) + (eval . (put 'run-with-state 'scheme-indent-function 1)) + (eval . (put 'wrap-program 'scheme-indent-function 1)) + (eval . (put 'with-imported-modules 'scheme-indent-function 1)) + (eval . (put 'with-extensions 'scheme-indent-function 1)) + + (eval . (put 'with-database 'scheme-indent-function 2)) + + (eval . (put 'call-with-container 'scheme-indent-function 1)) + (eval . (put 'container-excursion 'scheme-indent-function 1)) + (eval . (put 'eventually 'scheme-indent-function 1)) + + (eval . (put 'call-with-progress-reporter 'scheme-indent-function 1)) + + ;; This notably allows '(' in Paredit to not insert a space when the + ;; preceding symbol is one of these. + (eval . (modify-syntax-entry ?~ "'")) + (eval . (modify-syntax-entry ?$ "'")) + (eval . (modify-syntax-entry ?+ "'")))) + (emacs-lisp-mode . ((indent-tabs-mode . nil))) + (texinfo-mode . ((indent-tabs-mode . nil) + (fill-column . 72)))) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..c57d934 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,87 @@ +# Guile Feed --- Feed command-line interface. +# Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +# +# This file is part of Guile Feed. +# +# Guile Feed is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Guile Feed is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Guile Feed. If not, see <http://www.gnu.org/licenses/>. + +bin_SCRIPTS = scripts/feed + +# Handle substitution of fully-expanded Autoconf variables. +do_subst = $(SED) \ + -e 's,[@]GUILE[@],$(GUILE),g' + +scripts/feed: scripts/feed.in Makefile + $(AM_V_at)rm -f $@ $@-t + $(AM_V_at)$(MKDIR_P) "$(@D)" + $(AM_V_GEN)$(do_subst) < "$(srcdir)/$@.in" > "$@-t" + $(AM_V_at)chmod a+x,a-w "$@-t" && mv -f "$@-t" "$@" + +AM_V_GUILEC = $(AM_V_GUILEC_$(V)) +AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY)) +AM_V_GUILEC_0 = @echo " GUILEC " $@; + +MODULES = \ + feed.scm \ + feed/scripts/rss.scm \ + feed/ui.scm \ + rss/feeds.scm \ + rss/feeds/code.scm \ + rss/feeds/emacs.scm \ + rss/feeds/game.scm \ + rss/feeds/hardware.scm \ + rss/feeds/news.scm \ + rss/feeds/planet.scm \ + rss/feeds/video.ru.scm \ + rss/feeds/video.scm + +GO_FILES = $(MODULES:%.scm=%.go) + +nobase_dist_guilemodule_DATA = $(MODULES) +nobase_nodist_guileccache_DATA = $(GO_FILES) + +# Make sure source files are installed first, so that the mtime of +# installed compiled files is greater than that of installed source +# files. See +# <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html>. +guile_install_go_files = install-nobase_nodist_guileccacheDATA +$(guile_install_go_files): install-nobase_dist_guilemoduleDATA + +GUILEC_ENV = \ + GUILE_AUTO_COMPILE=0 + +GUILEC_OPTS = \ + -Warity-mismatch \ + -Wformat \ + -Wunbound-variable + +if GUIX_DIR + guix_module_part=":$(guixmoduledir)" + guix_ccache_part=":$(guixccachedir)" +else + guix_module_part= + guix_ccache_part= +endif + +# Guile PATHs shouldn't be unset: some guix modules want to load +# (gnutls) module, that's why 'guix' package propagates 'gnutls', i.e. +# a directory with gnutls module is placed in GUILE_LOAD_PATH. + +GUILEC_ENV += \ + GUILE_LOAD_PATH="$(abs_srcdir)$(guix_module_part):$$GUILE_LOAD_PATH" \ + GUILE_LOAD_COMPILED_PATH="$(abs_builddir)$(guix_ccache_part):$$GUILE_LOAD_COMPILED_PATH" + +$(GO_FILES): %.go: %.scm + -$(AM_V_GUILEC) $(GUILEC_ENV) \ + $(GUILD) compile $(GUILEC_OPTS) --output=$@ $< @@ -0,0 +1,2 @@ +Guile program for feeds generation. E.g. it could generate +elfeed-feeds for Elfeed Emacs package.
\ No newline at end of file diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..cb774bc --- /dev/null +++ b/bootstrap @@ -0,0 +1,5 @@ +#!/bin/sh +# Create the build system. + +set -e -x +exec autoreconf -vfi diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in new file mode 100755 index 0000000..c2aaf6d --- /dev/null +++ b/build-aux/pre-inst-env.in @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +# +# Usage: ./pre-inst-env COMMAND ARG... +# +# Run COMMAND in a pre-installation environment. Typical use is +# "./pre-inst-env feed build hello". + +# By default we may end up with absolute directory names that contain '..', +# which get into $GUILE_LOAD_PATH, leading to '..' in the module file names +# recorded by Guile. To avoid that, make sure we get a real absolute +# directory name. Additionally, use '-P' to get the canonical directory name +# so that Guile's 'relative' %file-port-name-canonicalization can actually +# work (see <http://bugs.gnu.org/17935>.) +abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd -P`" +abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd -P`" + +GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" +GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" +export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH + +# Define $PATH so that `feed' and friends are easily found. + +PATH="$abs_top_builddir/scripts:$abs_top_builddir:$PATH" +export PATH + +exec "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..1e836f3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,55 @@ +AC_INIT([Guile-Feed], [0.0.1], [go.wigust@gmail.com], [guile-feed], + [https://gitlab.com/wigust/guile-feed]) + +PKG_CHECK_MODULES([GUILE], [guile-2.2]) +GUILE_PKG([2.2]) +GUILE_PROGS +AC_ARG_WITH([guile-site-dir], + [AS_HELP_STRING([--with-guile-site-dir], + [installation directory for Guile (*.scm) files])], + [guilemoduledir="$withval"], + [guilemoduledir="$datarootdir/guile/site/$GUILE_EFFECTIVE_VERSION"]) +AC_SUBST([guilemoduledir]) +AC_MSG_CHECKING([for the Guile module directory]) +AC_MSG_RESULT([$guilemoduledir]) + +AC_ARG_WITH([guile-site-ccache-dir], + [AS_HELP_STRING([--with-guile-site-ccache-dir], + [installation directory for Guile compiled (*.go) files])], + [guileccachedir="$withval"], + [guileccachedir="$libdir/guile/$GUILE_EFFECTIVE_VERSION/site-ccache"]) +AC_SUBST([guileccachedir]) +AC_MSG_CHECKING([for the Guile ccache directory]) +AC_MSG_RESULT([$guileccachedir]) + +AC_ARG_WITH([guix-site-dir], + [AS_HELP_STRING([--with-guix-site-dir], + [directory with Guix modules (*.scm files)])], + [guixmoduledir="$withval"], + [guixmoduledir=""]) +AC_SUBST([guixmoduledir]) + +AC_ARG_WITH([guix-site-ccache-dir], + [AS_HELP_STRING([--with-guix-site-ccache-dir], + [directory with Guix compiled (*.go) files])], + [guixccachedir="$withval"], + [guixccachedir=""]) + +dnl If ccache dir is not specified, set it to the module dir. +AS_IF([test "x$guixccachedir" = "x" -a \ + "x$guixmoduledir" != "x"], + [guixccachedir="$guixmoduledir"]) + +AC_SUBST([guixccachedir]) + +AM_CONDITIONAL([GUIX_DIR], [test "x$guixmoduledir" != "x"]) + +AC_PROG_SED + +AM_INIT_AUTOMAKE([foreign]) +AC_CONFIG_FILES([Makefile]) + +AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in], + [chmod +x pre-inst-env]) + +AC_OUTPUT diff --git a/feed.scm b/feed.scm new file mode 100644 index 0000000..b1f204b --- /dev/null +++ b/feed.scm @@ -0,0 +1,3 @@ +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> + +(define-module (feed)) diff --git a/feed/scripts/rss.scm b/feed/scripts/rss.scm new file mode 100644 index 0000000..a9005d5 --- /dev/null +++ b/feed/scripts/rss.scm @@ -0,0 +1,107 @@ +;;; Guile Feed --- Feed command-line interface. +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +;;; +;;; This file is part of Guile Feed. +;;; +;;; Guile Feed is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation; either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Guile Feed is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Guile Feed. If not, see +;;; <http://www.gnu.org/licenses/>. + +(define-module (feed scripts rss) + #:use-module (guix scripts) + #:use-module (guix ui) + #:use-module (ice-9 match) + #:use-module (ice-9 pretty-print) + #:use-module (feed rss) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-11) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-37) + #:export (feed-rss)) + + +;;; +;;; Command-line options. +;;; + +(define %default-options + ;; Alist of default option values. + '()) + +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\o "output-file") #t #f + (lambda (opt name arg result) + (alist-cons 'output-file arg result))) + (option '(#\s "search") #t #f + (lambda (opt name arg result) + (alist-cons 'search arg result))) + (option '("show") #t #t + (lambda (opt name arg result) + (alist-cons 'show arg result))))) + +(define (show-help) + (display "Usage: guix rss -o FILE\n") + (newline) + (display " + -h, --help display this help and exit") + (display " + -V, --version display version information and exit") + (display " + -o, --output-file=FILE convert rss to LISP FILE") + (display " + -s, --search=REGEXP search in name and description using REGEXP") + (display " + --show=RSS show details about RSS") + (newline)) + + +;;; +;;; Entry point. +;;; + +(define (feed-rss . args) + (define (parse-options) + ;; Return the alist of option values. + (parse-command-line args %options (list %default-options) + #:build-options? #f)) + (let* ((opts (parse-options)) + (output (assoc-ref opts 'output-file)) + (search (assoc-ref opts 'search)) + (show (assoc-ref opts 'show))) + (cond (show + (leave-on-EPIPE + (for-each (cute feed->recutils <>) + (find-feeds-by-name show)))) + (search + (let* ((patterns (filter-map (match-lambda + (('search . rx) rx) + (_ #f)) + opts)) + (regexps (map (cut make-regexp* <> regexp/icase) patterns))) + (leave-on-EPIPE + (let-values (((rss scores) + (find-feeds-by-description regexps))) + (for-each (lambda (rss score) + (feed->recutils rss + #:extra-fields + `((relevance . ,score)))) + rss + scores))) + #t)) + (output + (with-output-to-file output + (lambda _ (pretty-print (feeds->lisp)))))))) diff --git a/feed/ui.scm b/feed/ui.scm new file mode 100644 index 0000000..3e1fdfe --- /dev/null +++ b/feed/ui.scm @@ -0,0 +1,118 @@ +;;; Guile Feed --- Feed command-line interface. +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +;;; +;;; This file is part of Guile Feed. +;;; +;;; Guile Feed is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation; either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Guile Feed is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Guile Feed. If not, see +;;; <http://www.gnu.org/licenses/>. + +(define-module (feed ui) + #:use-module (guix ui) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (ice-9 match) + #:use-module (ice-9 ftw) + #:export (feed-main)) + +(define (command-files) + "Return the list of source files that define Feed sub-commands." + (define directory + (and=> (search-path %load-path "feed.scm") + (compose (cut string-append <> "/feed/scripts") + dirname))) + + (define dot-scm? + (cut string-suffix? ".scm" <>)) + + (if directory + (scandir directory dot-scm?) + '())) + +(define (commands) + "Return the list of Feed command names." + (map (compose (cut string-drop-right <> 4) + basename) + (command-files))) + +(define (show-feed-usage) + (format (current-error-port) + "Try `feed --help' for more information.~%") + (exit 1)) + +(define (show-feed-help) + (format #t "Usage: feed COMMAND ARGS... +Run COMMAND with ARGS.\n") + (newline) + (format #t "COMMAND must be one of the sub-commands listed below:\n") + (newline) + ;; TODO: Display a synopsis of each command. + (format #t "~{ ~a~%~}" (sort (commands) string<?))) + +(define program-name + ;; Name of the command-line program currently executing, or #f. + (make-parameter #f)) + +(define (run-feed-command command . args) + "Run COMMAND with the given ARGS. Report an error when COMMAND is not +found." + (define module + (catch 'misc-error + (lambda () + (resolve-interface `(feed scripts ,command))) + (lambda - + (format (current-error-port) + "feed: ~a: command not found~%" command) + (show-feed-usage)))) + + (let ((command-main (module-ref module + (symbol-append 'feed- command)))) + (parameterize ((program-name command)) + ;; Disable canonicalization so we don't don't stat unreasonably. + (with-fluids ((%file-port-name-canonicalization #f)) + (dynamic-wind + (const #f) + (lambda () + (apply command-main args)) + (lambda () + ;; Abuse 'exit-hook' (which is normally meant to be used by the + ;; REPL) to run things like profiling hooks upon completion. + (run-hook exit-hook))))))) + +(define (show-feed-usage) + (format (current-error-port) + "Try `feed --help' for more information.~%") + (exit 1)) + +(define (run-feed . args) + "Run the 'feed' command defined by command line ARGS." + (define option? (cut string-prefix? "-" <>)) + + ;; The default %LOAD-EXTENSIONS includes the empty string, which doubles the + ;; number of 'stat' calls per entry in %LOAD-PATH. Shamelessly remove it. + (set! %load-extensions '(".scm")) + + (match args + (() + (format (current-error-port) + "feed: missing command name~%") + (show-feed-usage)) + ((or ("-h") ("--help")) + (show-feed-help)) + ((command args ...) + (apply run-feed-command + (string->symbol command) + args)))) + +(define (feed-main arg0 . args) + (apply run-feed args)) diff --git a/guix.scm b/guix.scm new file mode 100644 index 0000000..731cd32 --- /dev/null +++ b/guix.scm @@ -0,0 +1,129 @@ +;;; Guile Feed --- Feed command-line interface. +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +;;; +;;; This file is part of Guile Feed. +;;; +;;; Guile Feed is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation; either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Guile Feed is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Guile Feed. If not, see +;;; <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This file contains Guix package for development version of Guile +;; Feed. To build or install, run: +;; +;; guix build --file=guix.scm +;; guix package --install-from-file=guix.scm + +;;; Code: + +(use-modules (gnu packages autotools) + (gnu packages gnupg) + (gnu packages guile) + (gnu packages package-management) + (gnu packages pkg-config) + (gnu packages tls) + (guix build utils) + (guix build-system gnu) + (guix gexp) + (guix git-download) + (guix packages) + (ice-9 popen) + (ice-9 rdelim) + ((guix licenses) #:prefix license:)) + +(define %source-dir (dirname (current-filename))) + +(define (git-output . args) + "Execute 'git ARGS ...' command and return its output without trailing +newspace." + (with-directory-excursion %source-dir + (let* ((port (apply open-pipe* OPEN_READ "git" args)) + (output (read-string port))) + (close-port port) + (string-trim-right output #\newline)))) + +(define (current-commit) + (git-output "log" "-n" "1" "--pretty=format:%H")) + +(define guile-feed + (let ((commit (current-commit))) + (package + (name "guile-feed") + (version (string-append "0.0.1" "-" (string-take commit 7))) + (source (local-file %source-dir + #:recursive? #t + #:select? (git-predicate %source-dir))) + (build-system gnu-build-system) + (arguments + `(#:modules ((guix build gnu-build-system) + (guix build utils) + (srfi srfi-26) + (ice-9 popen) + (ice-9 rdelim)) + #:phases + (modify-phases %standard-phases + (add-after 'install 'wrap-program + (lambda* (#:key inputs outputs #:allow-other-keys) + ;; Make sure the 'guix' command finds GnuTLS, + ;; Guile-JSON, and Guile-Git automatically. + (let* ((out (assoc-ref outputs "out")) + (guile (assoc-ref inputs "guile")) + (gcrypt (assoc-ref inputs "guile-gcrypt")) + (gnutls (assoc-ref inputs "gnutls")) + (guix (assoc-ref inputs "guix")) + (json (assoc-ref inputs "guile-json")) + (deps (list gcrypt gnutls guix json out)) + (effective + (read-line + (open-pipe* OPEN_READ + (string-append guile "/bin/guile") + "-c" "(display (effective-version))"))) + (path (string-join + (map (cut string-append <> + "/share/guile/site/" + effective) + deps) + ":")) + (gopath (string-join + (map (cut string-append <> + "/lib/guile/" effective + "/site-ccache") + deps) + ":"))) + + (wrap-program (string-append out "/bin/feed") + `("GUILE_LOAD_PATH" ":" prefix (,path)) + `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,gopath))) + + #t)))))) + (native-inputs + `(("autoconf" ,autoconf) + ("automake" ,automake) + ("pkg-config" ,pkg-config))) + (inputs + `(("gnutls" ,gnutls) + ("guile" ,guile-2.2) + ("guile-gcrypt" ,guile-gcrypt) + ("guile-json" ,guile-json) + ("guix" ,guix))) + (home-page "https://gitlab.com/wigust/guile-feed") + (synopsis "Command-line RSS feeds manager") + (description + "This package provides a command-line program to manage RSS feeds +written in Guile.") + (license license:gpl3+)))) + +guile-feed + +;;; guix.scm ends here diff --git a/scripts/feed.in b/scripts/feed.in new file mode 100755 index 0000000..dfa866d --- /dev/null +++ b/scripts/feed.in @@ -0,0 +1,27 @@ +#!@GUILE@ \ +--no-auto-compile -e main -s +!# + +;;; Guile Feed --- Feed command-line interface. +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +;;; +;;; This file is part of Guile Feed. +;;; +;;; Guile Feed is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation; either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Guile Feed is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Guile Feed. If not, see +;;; <http://www.gnu.org/licenses/>. + +(define* (main #:optional (args (command-line))) + (let ((feed-main (module-ref (resolve-interface '(feed ui)) + 'feed-main))) + (exit (apply feed-main args)))) diff --git a/tests/rss.scm b/tests/rss.scm new file mode 100644 index 0000000..843368c --- /dev/null +++ b/tests/rss.scm @@ -0,0 +1,40 @@ +;;; Guile Feed --- Feed command-line interface. +;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> +;;; +;;; This file is part of Guile Feed. +;;; +;;; Guile Feed is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation; either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Guile Feed is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Guile Feed. If not, see +;;; <http://www.gnu.org/licenses/>. + +(define-module (test-feed) + #:use-module (guix tests) + #:use-module (feed scripts rss) + #:use-module (ice-9 match) + #:use-module (srfi srfi-64)) + +(test-begin "search") + +(test-assert "feed-rss-search" + (string=? (with-output-to-string + (lambda () + (feed-rss "-s" "planet-gnu"))) + "\ +name: planet-gnu +description: Gnu planet. +link: http://planet.gnu.org/atom.xml +relevance: 15 + +")) + +(test-end "search") |
