Opened 9 years ago

Closed 7 years ago

#717 closed defect (wontfix)

args egg does not call option body for missing args

Reported by: Jim Ursetto Owned by: Jim Ursetto
Priority: not urgent at all Milestone:
Component: extensions Version: 4.7.x
Keywords: args command-line Cc:
Estimated difficulty:

Description

User alanh reports that for options with required arguments, the option processor body is not called with ARG #f when the argument is missing.

(use args)
(define opts (list (args:make-option (a apple) #:required "..."
                                     (cond ((not arg) (error "usage...")))))))

(receive (options operands) (args:parse (command-line-arguments) opts)
         (print "-- never should have gotten here on `test.scm -a'"))

This was in fact the intended behavior -- when the arg is missing, the option is simply treated as not present on the command line, so you can handle it like you would any other missing option. For example

(receive (options operands) (args:parse (command-line-arguments) opts)
         (unless (assq 'apple options) (error "Missing option -a"))
         (print "-- never should have gotten here on `test.scm -a'"))

The rationale is that if the option is formatted invalidly, the program should just revert to the default value for the option.

It's possible to change this behavior, but note that missing optional and required arguments can't be detected unless they're absolutely last on the command-line, as SRFI 37 doesn't distinguish options from arguments (e.g. by using initial dash). So the utility of this change would be very limited.

Change History (2)

comment:1 Changed 9 years ago by felix winkelmann

Milestone: 4.8.0

comment:2 Changed 7 years ago by Jim Ursetto

Resolution: wontfix
Status: newclosed

As noted above the utility of this change is too low to be worth it, due to limitations in SRFI 37.

Note: See TracTickets for help on using tickets.