<commit_before>#lang scheme/base
(require scheme/cmdline
         raco/command-name
         setup/pack
         setup/getinfo
         compiler/distribute)

(define verbose (make-parameter #f))

(define collection? (make-parameter #f))

(define default-plt-name "archive")

(define plt-name (make-parameter default-plt-name))
(define plt-files-replace (make-parameter #f))
(define plt-files-plt-relative? (make-parameter #f))
(define plt-files-plt-home-relative? (make-parameter #f))
(define plt-force-install-dir? (make-parameter #f))
(define plt-setup-collections (make-parameter null))
(define plt-include-compiled (make-parameter #f))

(define-values (plt-output source-files)
  (command-line
   #:program (short-program+command-name)
   #:once-each
   [("--collect") "Pack collections instead of files and directories"
    (collection? #t)]
   [("--plt-name") name "Set the printed <name> describing the archive"
    (plt-name name)]
   [("--replace") "Files in archive replace existing files when unpacked"
    (plt-files-replace #t)]
   [("--at-plt") "Files/dirs in archive are relative to user's add-ons directory"
    (plt-files-plt-relative? #t)]
   #:once-any
   [("--all-users") "Files/dirs in archive go to PLT installation if writable"
    (plt-files-plt-home-relative? #t)]
   [("--force-all-users") "Files/dirs forced to PLT installation"
    (plt-files-plt-home-relative? #t) (plt-force-install-dir? #t)]
   #:once-each
   [("--include-compiled") "Include \"compiled\" subdirectories in the archive"
    (plt-include-compiled #t)]
   #:multi
   [("++setup") collect "Setup <collect> after the archive is unpacked"
    (plt-setup-collections (append (plt-setup-collections) (list collect)))]
   #:once-each
   [("-v") "Verbose mode"
    (verbose #t)]
   #:args (dest-file . file)
   (values dest-file file)))

(if (not (collection?))
    ;; Files and directories
    (begin
      (for ([fd source-files])
        (unless (relative-path? fd)
          (error 'mzc
                 "file/directory is not relative to the current directory: \"~a\""
                 fd)))
      (pack-plt plt-output
                (plt-name)
                source-files
                #:collections (map list (plt-setup-collections))
                #:file-mode (if (plt-files-replace) 'file-replace 'file)
                #:plt-relative? (or (plt-files-plt-relative?)
                                    (plt-files-plt-home-relative?))
                #:at-plt-home? (plt-files-plt-home-relative?)<commit_msg>Use "<path>" instead of a misleading "<file>", improve doc line for `--collect'.<commit_after>#lang scheme/base
(require scheme/cmdline
         raco/command-name
         setup/pack
         setup/getinfo
         compiler/distribute)

(define verbose (make-parameter #f))

(define collection? (make-parameter #f))

(define default-plt-name "archive")

(define plt-name (make-parameter default-plt-name))
(define plt-files-replace (make-parameter #f))
(define plt-files-plt-relative? (make-parameter #f))
(define plt-files-plt-home-relative? (make-parameter #f))
(define plt-force-install-dir? (make-parameter #f))
(define plt-setup-collections (make-parameter null))
(define plt-include-compiled (make-parameter #f))

(define-values (plt-output source-files)
  (command-line
   #:program (short-program+command-name)
   #:once-each
   [("--collect") "<path>s specify collections instead of files/dirs"
    (collection? #t)]
   [("--plt-name") name "Set the printed <name> describing the archive"
    (plt-name name)]
   [("--replace") "Files in archive replace existing files when unpacked"
    (plt-files-replace #t)]
   [("--at-plt") "Files/dirs in archive are relative to user's add-ons directory"
    (plt-files-plt-relative? #t)]
   #:once-any
   [("--all-users") "Files/dirs in archive go to PLT installation if writable"
    (plt-files-plt-home-relative? #t)]
   [("--force-all-users") "Files/dirs forced to PLT installation"
    (plt-files-plt-home-relative? #t) (plt-force-install-dir? #t)]
   #:once-each
   [("--include-compiled") "Include \"compiled\" subdirectories in the archive"
    (plt-include-compiled #t)]
   #:multi
   [("++setup") collect "Setup <collect> after the archive is unpacked"
    (plt-setup-collections (append (plt-setup-collections) (list collect)))]
   #:once-each
   [("-v") "Verbose mode"
    (verbose #t)]
   #:args (dest-file . path)
   (values dest-file path)))

(if (not (collection?))
    ;; Files and directories
    (begin
      (for ([fd source-files])
        (unless (relative-path? fd)
          (error 'mzc
                 "file/directory is not relative to the current directory: \"~a\""
                 fd)))
      (pack-plt plt-output
                (plt-name)
                source-files
                #:collections (map list (plt-setup-collections))
                #:file-mode (if (plt-files-replace) 'file-replace 'file)
                #:plt-relative? (or (plt-files-plt-relative?)
                                    (plt-files-plt-home-relative?))
                #:at-plt-home? (plt-files-plt-home-relative?)
{'fraction_non_alphanumeric': 0.15903282877924121, 'fraction_numerical': 0.0, 'mean_word_length': 2.771682727946627, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4314096', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1586, 'n_words': 413}