<commit_before>#lang racket/base
#|
This module contains code that implements the `planet' command-line tool.
  
PLANNED FEATURES:
* Disable a package without removing it (disabling meaning
  that if it's a tool it won't start w/ DrRacket, etc)
|#
  (require (only-in racket/path simple-form-path)
           net/url
           racket/file
           racket/match
           raco/command-name
           
           (only-in planet/resolver download?)
           planet/config
           planet/private/planet-shared
           planet/util
           planet/private/command)
  (provide start)
  
  (define erase? (make-parameter #f))
  (define displayer (make-parameter (λ () (show-installed-packages))))
  (define quiet-unlink? (make-parameter #f))

  (define (read-from-string str)
    (read
      (if (bytes? str) (open-input-bytes str) (open-input-string str))))

  
  (define (start raco?)

    (make-directory* (PLANET-DIR))
    (make-directory* (CACHE-DIR))
    (planet-logging-to-stdout #t)
    
    (svn-style-command-line
     #:program (short-program+command-name)
     #:argv (current-command-line-arguments)
     "The Racket command-line tool for manipulating packages installed by PLaneT."
     ["create" "create a PLaneT archive from a directory"
      "\nCreate a PLaneT archive in the current directory whose contents are the directory <path>."
      #:once-each
      [("-f" "--force") ("force a package to be created even if its info.rkt file contains"
                         "errors.")
       (force-package-building? #t)]
      #:args (path)
      (do-archive path)]
     ["install" "download and install a package"
      "
Download and install the package that
   (require (planet \"file.rkt\" (<owner> <pkg> <maj> <min>)))
would install"
      #:args (owner pkg maj min)
      (begin
        (verify-package-name pkg)
        (download/install owner pkg maj min))]
     ["remove" "remove a package from the local cache"
      "
Remove the specified package from the local cache, optionally also removing its distribution file"
      #:once-each 
      [("-e" "--erase") 
       ("also remove the package's distribution file from the"
        "uninstalled-package cache")
       (erase? #t)]
      #:args (owner pkg maj min)
      ((if (erase?) erase remove) owner pkg maj min)]
     ["show" "list the packages installed in the local cache"
      "\nList the packages installed in the local cache"
      #:once-any
      [("-p" "--packages") "show packages only (default)" (displayer show-installed-packages)]
      [("-l" "--linkage")  "show linkage table only"      (displayer show-linkage)]
      [("-a" "--all")      "show packages and linkage"    (displayer (λ () (show-installed-packages) (newline) (show-linkage)))]
      #:args ()
      ((displayer))]
     ["clearlinks" "clear the linkage table, allowing upgrades"
      "\nClear the linkage table, allowing upgrades"
      #:args ()
      (unlink-all)]
     ["fileinject" "install a local file to the planet cache"
       "
Install local file <plt-file> into the planet cache as though it had been downloaded from the planet server.  The installed package has path
  (planet (<owner> <plt-file's filename> <maj> <min>))"
       #:args (owner plt-file maj min)
       (install-plt-file plt-file owner maj min)]
     ["link" "create a package development link"
      "\nCreate a development link between the specified package specifier and the specified directory name"
      #:args (owner pkg maj min path)
      (begin
        (verify-package-name pkg)
        (add-hard-link-cmd owner pkg maj min path))]
     ["unlink" "remove a package development link"
      "\nRemove development link associated with the given package"
      #:once-each
      [("-q" "--quiet") "don't signal an error on nonexistent links" (quiet-unlink? #t)]
      #:args (owner pkg maj min)
      (begin<commit_msg>fix 'planet remove' commandline argument checking<commit_after>#lang racket/base
#|
This module contains code that implements the `planet' command-line tool.
  
PLANNED FEATURES:
* Disable a package without removing it (disabling meaning
  that if it's a tool it won't start w/ DrRacket, etc)
|#
  (require (only-in racket/path simple-form-path)
           net/url
           racket/file
           racket/match
           raco/command-name
           
           (only-in planet/resolver download?)
           planet/config
           planet/private/planet-shared
           planet/util
           planet/private/command)
  (provide start)
  
  (define erase? (make-parameter #f))
  (define displayer (make-parameter (λ () (show-installed-packages))))
  (define quiet-unlink? (make-parameter #f))

  (define (read-from-string str)
    (read
      (if (bytes? str) (open-input-bytes str) (open-input-string str))))

  
  (define (start raco?)

    (make-directory* (PLANET-DIR))
    (make-directory* (CACHE-DIR))
    (planet-logging-to-stdout #t)
    
    (svn-style-command-line
     #:program (short-program+command-name)
     #:argv (current-command-line-arguments)
     "The Racket command-line tool for manipulating packages installed by PLaneT."
     ["create" "create a PLaneT archive from a directory"
      "\nCreate a PLaneT archive in the current directory whose contents are the directory <path>."
      #:once-each
      [("-f" "--force") ("force a package to be created even if its info.rkt file contains"
                         "errors.")
       (force-package-building? #t)]
      #:args (path)
      (do-archive path)]
     ["install" "download and install a package"
      "
Download and install the package that
   (require (planet \"file.rkt\" (<owner> <pkg> <maj> <min>)))
would install"
      #:args (owner pkg maj min)
      (begin
        (verify-package-name pkg)
        (download/install owner pkg maj min))]
     ["remove" "remove a package from the local cache"
      "
Remove the specified package from the local cache, optionally also removing its distribution file"
      #:once-each 
      [("-e" "--erase") 
       ("also remove the package's distribution file from the"
        "uninstalled-package cache")
       (erase? #t)]
      #:args (owner pkg maj min)
      (begin
        (verify-package-name pkg)
        ((if (erase?) erase remove) owner pkg maj min))]
     ["show" "list the packages installed in the local cache"
      "\nList the packages installed in the local cache"
      #:once-any
      [("-p" "--packages") "show packages only (default)" (displayer show-installed-packages)]
      [("-l" "--linkage")  "show linkage table only"      (displayer show-linkage)]
      [("-a" "--all")      "show packages and linkage"    (displayer (λ () (show-installed-packages) (newline) (show-linkage)))]
      #:args ()
      ((displayer))]
     ["clearlinks" "clear the linkage table, allowing upgrades"
      "\nClear the linkage table, allowing upgrades"
      #:args ()
      (unlink-all)]
     ["fileinject" "install a local file to the planet cache"
       "
Install local file <plt-file> into the planet cache as though it had been downloaded from the planet server.  The installed package has path
  (planet (<owner> <plt-file's filename> <maj> <min>))"
       #:args (owner plt-file maj min)
       (install-plt-file plt-file owner maj min)]
     ["link" "create a package development link"
      "\nCreate a development link between the specified package specifier and the specified directory name"
      #:args (owner pkg maj min path)
      (begin
        (verify-package-name pkg)
        (add-hard-link-cmd owner pkg maj min path))]
     ["unlink" "remove a package development link"
      "\nRemove development link associated with the given package"
      #:once-each
      [("-q" "--quiet") "don't signal an error on nonexistent links" (quiet-unlink? #t)]
      #:args (owner pkg maj min)
      (begin
{'fraction_non_alphanumeric': 0.12155260469867211, 'fraction_numerical': 0.0, 'mean_word_length': 2.638179284718997, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '12825', 'n_tokens_mistral': 2338, 'n_tokens_neox': 2242, 'n_words': 813}