#!/usr/bin/guile
!#

(use-modules (sph) (sph cli) (sph pack) (sph lang indent-syntax))
(define program-dependencies (q ("scrypt" "tar" "zstd")))

(define description
  (string-append "one program for file and directory compounding, compression and encryption\n"
    "current tools: tar, xz, scrypt"))

(define about
  (qq
    ( ("description" (unquote description))
      ("features" "archiving - compression - encryption"
        "multiple files are automatically archived" "unpack removes layers")
      ("depends on" (unquote (string-join program-dependencies " ")))
      ("maintainer and copyright" "sph@posteo.eu | http://sph.mn") ("license" "GPLv3"))))

(define (pack-cli)
  (let
    (options
      ( (cli-create #:options
          (q
            ( (compression #:names #\c) (encryption #:names #\e)
              (read-paths #:names #\p #:value-required? #t #:type string)
              (target #:names #\t #:value-required? #t #:type string)
              (auto-compression #:names #\i
                #:value-optional? #f
                #:type number
                #:description
                "add compression if source is below a certain size. the value is in megabits.")
              (unpack #:names #\u) (delete-input-files #:names #\d) (dry-run) ((source-path ...))))
          #:description description
          #:about (nullary (prefix-tree->indent-tree about)))))
    (pack options)))

(pack-cli)