File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
1
(declare (uses functions options util convolutional full pooling))
2
2
3
- (use getopt-long)
3
+ (use getopt-long srfi-13 )
4
4
5
5
(define prog-name "layer")
6
6
18
18
(desc (cadr def))
19
19
(grammar (caddr def)))
20
20
(format #t " Usage: ~A ~A [OPTIONS]\n\n ~A.\n\n " prog-name command desc)
21
- (print " Options:" )
22
- (print (usage grammar))))
21
+ (print " Required parameters:\n " )
22
+ (print (usage (filter required? grammar)))
23
+ (print " Optional:\n " )
24
+ (print (usage (filter (lambda (o ) (not (required? o))) grammar)))))
23
25
24
26
(define (print-program-usage #!optional error)
25
27
(when error (begin (print error) (newline)))
26
28
(format #t " Usage: ~A COMMAND [OPTIONS]\n\n ~A.\n\n " prog-name prog-desc)
27
- (print " Commands:" )
28
- (for-each (lambda (c ) (print " " (car c) " \t\t " (cadr c))) commands))
29
+ (print " Commands:\n " )
30
+ (let ((max-command-width (apply max (map (compose string-length car) commands))))
31
+ (for-each (lambda (c )
32
+ (let* ((spaces (+ 4 (- max-command-width (string-length (car c)))))
33
+ (sep (make-string spaces #\ )))
34
+ (print " " (car c) sep (cadr c))))
35
+ commands))
36
+ (format #t " \n See '~A COMMAND' to read more about a specific command.\n " prog-name))
29
37
30
38
(define (parse-options command args grammar )
31
39
(handle-exceptions
You can’t perform that action at this time.
0 commit comments