1. David Krentzlin
  2. mira.cl

Commits

David Krentzlin  committed 0bbbfb8 Draft

more refinements

  • Participants
  • Parent commits 145f2d0
  • Branches default

Comments (0)

Files changed (1)

File mira.core/src/processor.lisp

View file
  • Ignore whitespace
     (let* ((argument-list (argument-string->argument-list argument-string))
 	   (cmd-closure   (body command))
 	   (cmd-opts      (command-line-options command))
-	   (first-arg     (car argument-list)))
+	   (first-arg     (car argument-list))
+	   (no-args-ok    (allow-no-args command)))
       (if (and first-arg (stringp first-arg) (equal (string-downcase (car argument-list)) "help"))
           (cmd-answer command-env (help command))
 	  (handler-case 
-	      (progn
-		(if (and (not argument-list) (not (no-args-allowed command)))
-		    (cmd-answer command-env (usage command))
-		    (if cmd-opts
-			(multiple-value-bind (args options errors) (getopt argument-list cmd-opts)
-			  (if errors
-			      (cmd-answer command-env (usage command))
-			      (apply cmd-closure command-env options args)))
-			(apply cmd-closure command-env nil argument-list))))
+	      (progn		
+		(multiple-value-bind (args options errors) (getopt argument-list cmd-opts)
+		  (if (or errors (and (not no-args-ok (not args))))
+		      (cmd-answer command-env (usage command))
+		      (apply cmd-closure command-env options args)))
+		(apply cmd-closure command-env nil argument-list))
 	     (error ()
 	       (format t "Have an error~%")
 	       (cmd-answer command-env (usage command))))