如何通过给出命令行argumands从终端调用racket过程
我有一个叫foo.rkt的拍子文件,在这个文件里我有一个叫textify的程序,它需要两个参数。现在我如何从终端调用这个过程?我想做的只是:如何通过给出命令行argumands从终端调用racket过程,racket,Racket,我有一个叫foo.rkt的拍子文件,在这个文件里我有一个叫textify的程序,它需要两个参数。现在我如何从终端调用这个过程?我想做的只是: > racket foo.rkt myfirstarg mysecondarg 然后我希望这个调用激活(textify myfirstarg mysecondarg)过程。这可能吗 以下是foo.rkt的内容: #lang racket (require wxme) (provide (contract-out [textify
> racket foo.rkt myfirstarg mysecondarg
然后我希望这个调用激活(textify myfirstarg mysecondarg)
过程。这可能吗
以下是foo.rkt的内容:
#lang racket
(require wxme)
(provide
(contract-out
[textify (-> path-string? path-string? void?)]))
(define (textify in out)
(call-with-input-file in
(λ (in-port)
(call-with-output-file out
(λ (out-port)
(copy-port (wxme-port->text-port in-port) out-port))
#:exists 'truncate))))
您只需在文件中的最后一个表达式中执行此操作:
(apply textify (vector->list (current-command-line-arguments)))
如果你正在制作一个有开关的更高级的程序,你可以用它来为你做这件事