Extract RC loading from main

This commit is contained in:
Tom Willemse 2014-03-02 00:12:58 +01:00
parent 7a0c947c10
commit 53db54e71d

View file

@ -52,6 +52,15 @@
(for-each print-repository-location (for-each print-repository-location
(sort repositories repository-location<?))) (sort repositories repository-location<?)))
(define (load-rc)
"Load the RC file for user customizations."
(let ((cfg (config-file "rc.scm")))
(when (file-exists? cfg)
(save-module-excursion
(lambda ()
(set-current-module (resolve-module '(gitto main)))
(primitive-load cfg))))))
(define (maybe-install-hooks. repo) (define (maybe-install-hooks. repo)
"Install hooks for REPO unless it's excluded." "Install hooks for REPO unless it's excluded."
(unless (member (repo-name repo) config-exclusion-list) (unless (member (repo-name repo) config-exclusion-list)
@ -273,17 +282,12 @@ Displays version and some copyright information."
(define (main args) (define (main args)
"Parse the command line options and run the appropriate functions." "Parse the command line options and run the appropriate functions."
(let ((cfg (config-file "rc.scm"))) (load-rc)
(when (file-exists? cfg)
(save-module-excursion
(lambda ()
(set-current-module (resolve-module '(gitto main)))
(primitive-load cfg))))
(let* ((command-spec (cdr (member "gitto" args string-suffix?))) (let* ((command-spec (cdr (member "gitto" args string-suffix?)))
(command-specified? (not (eq? command-spec '()))) (command-specified? (not (eq? command-spec '())))
(command (car (if command-specified? command-spec '("list"))))) (command (car (if command-specified? command-spec '("list")))))
(if (command? command) (if (command? command)
(apply (command-function command) (apply (command-function command)
(if command-specified? (cdr command-spec) '())) (if command-specified? (cdr command-spec) '()))
(format #t "Unknown command: ~a~%" (car command-spec)))))) (format #t "Unknown command: ~a~%" (car command-spec)))))