Skip to content

Commit

Permalink
サブコマンドなしでファイル名がコマンドラインに与えられた場合にデフォルトのコマンドを実行するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
moratori committed Dec 7, 2021
1 parent 7f1d319 commit 0c68fc6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/ui/batch.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
(rewrite-rule.dst x))))
rules)
:test #'term=)))
(%stdout "YES~%")
(%stdout "YES~%~%")
(%stdout "(VAR ~{~A~^ ~})~%" variables)
(%stdout "(RULES~%~{ ~A~%~})~%" rules)
(%stdout "(COMMENT~% ~A~%)~%" ordering)))
Expand All @@ -71,12 +71,16 @@
(defun main (args)
(let ((subcommand (first args))
(subcommand-args (cdr args)))
(if (or (not (scan "[a-zA-Z]+" subcommand))
(> (length subcommand) 9))
(progn
(%stdout "malformed command: ~A~%" subcommand)
(help))
(handler-case
(cond
((probe-file subcommand)
; execute default command for a file
(%perform-command :COMPLETE (list subcommand)))
((or (not (scan "[a-zA-Z]+" subcommand))
(> (length subcommand) 9))
(%stdout "malformed command: ~A~%" subcommand)
(help))
(t
(handler-case
(let* ((command-name
(intern (string-upcase subcommand)
(find-package "KEYWORD")))
Expand All @@ -88,5 +92,5 @@
(%perform-command command-name subcommand-args)
(%stdout "unimplemented command: ~A~%" subcommand)))
(condition (con)
(%stdout "unhandled condition occurred: ~A~%quit~%" con))))))
(%stdout "unhandled condition occurred: ~A~%quit~%" con)))))))

0 comments on commit 0c68fc6

Please sign in to comment.