www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

pkg-info.rkt (775B)


      1 #lang racket/base
      2 (require pkg/lib
      3          racket/cmdline
      4          net/url)
      5 
      6 (define dest-file #f)
      7 
      8 (define catalog
      9   (command-line
     10    #:once-each
     11    [("-o") file "Output file"
     12     (set! dest-file file)]
     13    #:args
     14    (catalog)
     15    catalog))
     16 
     17 (define catalog-url
     18   (if (regexp-match? #rx"^[a-z]+:" catalog)
     19       (string->url catalog)
     20       (path->url (path->complete-path catalog))))
     21 
     22 (define details
     23   (parameterize ([current-pkg-catalogs (list catalog-url)])
     24     (get-all-pkg-details-from-catalogs)))
     25 
     26 (define (write-out o)
     27   (write details o)
     28   (newline o))
     29 
     30 (if dest-file
     31     (call-with-output-file* dest-file
     32                             #:exists 'truncate/replace
     33                             write-out)
     34     (write-out (current-output-port)))
     35 
     36 
     37 (module test racket/base)