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
(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)
"Install hooks for REPO unless it's excluded."
(unless (member (repo-name repo) config-exclusion-list)
@ -273,12 +282,7 @@ Displays version and some copyright information."
(define (main args)
"Parse the command line options and run the appropriate functions."
(let ((cfg (config-file "rc.scm")))
(when (file-exists? cfg)
(save-module-excursion
(lambda ()
(set-current-module (resolve-module '(gitto main)))
(primitive-load cfg))))
(load-rc)
(let* ((command-spec (cdr (member "gitto" args string-suffix?)))
(command-specified? (not (eq? command-spec '())))
@ -286,4 +290,4 @@ Displays version and some copyright information."
(if (command? command)
(apply (command-function command)
(if command-specified? (cdr command-spec) '()))
(format #t "Unknown command: ~a~%" (car command-spec))))))
(format #t "Unknown command: ~a~%" (car command-spec)))))