#!/usr/bin/guile !# (import (sph) (sph alist) (sph rate) (sph cli) (sph filesystem) (sph string)) (define program-description "this program changes the rating of files relative to their current one. direction can be \"up\" or \"down\". a rating is designated by a numeric directory in the path unequal to the current path. see the \"rate\" program for more information") (define command-line-interface (cli-create #:description program-description #:options (q (((direction difference path ...) #f))))) (define (rate-modify-cli) (let (options (command-line-interface)) (alist-bind options (direction difference path) (each (let (difference (* (if (string-equal? "up" direction) -1 1) (string->number difference))) (l (path) (and-let* ( (current-rating (rate-path->rating (realpath* path))) (new-rating (max 0 (+ current-rating difference)))) (if (not (equal? current-rating new-rating)) (rate new-rating path))))) path)))) (rate-modify-cli)