aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-03-01 20:06:12 +0100
committerGravatar Tom Willemse2014-03-01 20:06:12 +0100
commit2dd972c770ce94faabd47ad28e97fcfebb74ebd5 (patch)
tree7b0f941f966ffbef890c403c776e8423bc31ea3f
parente72c0930573377c52b41bcb45b40d270cbbe8cc4 (diff)
downloadgitto-2dd972c770ce94faabd47ad28e97fcfebb74ebd5.tar.gz
gitto-2dd972c770ce94faabd47ad28e97fcfebb74ebd5.zip
Reorder commands
-rw-r--r--gitto/main.scm270
1 files changed, 135 insertions, 135 deletions
diff --git a/gitto/main.scm b/gitto/main.scm
index 2600c88..1b9d742 100644
--- a/gitto/main.scm
+++ b/gitto/main.scm
@@ -46,18 +46,6 @@ set in the current environment."
(define (data-dir) (storage-dir "XDG_DATA_HOME" "/.local/share"))
(define (data-file file) (string-append (data-dir) "/" file))
-(define-command (version)
- "Display version information."
- "Usage: gitto version
-
-Displays version and some copyright information."
- (display "gitto 0.1.0") (newline)
- (display "Copyright (C) 2012 Tom Willemse") (newline)
- (display "This program comes with ABSOLUTELY NO WARRANTY.") (newline)
- (display "You may redistribute copies of this program") (newline)
- (display "under the terms of the GNU General Public License.") (newline)
- (display "For more information about these matters, see the file named COPYING.") (newline))
-
(define (registered? repo)
"Check if REPO has been registered."
(or (member repo repositories same-repository?)
@@ -91,14 +79,65 @@ Displays version and some copyright information."
(write repos port)
(close-port port)))
-(define-command (check repository)
- "Check to see if a repository has been registered."
- "Usage: gitto check REPO
+(define (list-repository-locations)
+ "List the registered locations of repositories."
+ (for-each
+ (lambda (repo)
+ (display (repo-location repo))
+ (newline))
+ (sort repositories
+ (lambda (s1 s2)
+ (string<? (repo-location s1) (repo-location s2))))))
-Checks whether or not the git repository REPO has been registered with
-gitto."
- (format #t "Repository is~a registered~%"
- (if (known? repository) "" " not")))
+(define (show-global-config)
+ "Show the template specified in `global-config'."
+ (write-config global-config))
+
+(define (update-repo-config repo)
+ "Merge the configured configuration with REPO's configuration.
+
+Don't do anything if REPO has been added to `config-exclusion-list'."
+ (unless (member (repo-name repo) config-exclusion-list)
+ (write-config
+ (merge-config (repo-name repo)
+ (read-config (repo-location repo))
+ global-config)
+ (string-append (repo-location repo) "/.git/config"))))
+
+(define* (update-config #:optional repo)
+ "Merge the configured configuration with all repositories."
+ (if repo
+ (if (known? repo)
+ (update-repo-config (make <repository> repo))
+ (format #t "Unknown repository: ~a~%" repo))
+ (for-each update-repo-config repositories)))
+
+(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))))
+
+ (let* ((command-spec (cdr (member "gitto" args string-suffix?)))
+ (command-specified? (not (eq? command-spec '())))
+ (command (car (if command-specified? command-spec '("list")))))
+ (if (command? command)
+ (apply (command-function command)
+ (if command-specified? (cdr command-spec) '()))
+ (format #t "Unknown command: ~a~%" (car command-spec))))))
+
+(define repositories-file (data-file "repos.scm"))
+
+(define repositories
+ (if (file-exists? repositories-file)
+ (let* ((port (open-input-file repositories-file))
+ (result (read port)))
+ (close-port port)
+ (map-in-order (lambda (repo) (make <repository> repo)) result))
+ '()))
(define-command (add repository)
"Register a repository."
@@ -126,84 +165,14 @@ registered."
(display "Repository already registered."))
(newline))
-(define-command (remove repository)
- "Unregister a repository."
- "Usage: gitto remove REPO
-
-Removes REPO from the registered repository list. This command will
-fail if REPO does not indicate a git repository of if it hasn't been
-registered."
- (unless (member repository repositories same-repository?)
- (set! repository (realpath repository)))
-
- (if (known? repository)
- (begin
- (set! repositories
- (delete repository repositories same-repository?))
- (save-repositories-list)
- (simple-format #t "Repository ~A removed." repository))
- (display "Not a registered repository."))
- (newline))
-
-(define-command (list . args)
- "List information about every repository."
- "Usage: gitto list
- gitto list locations
-
-The first form shows an overview of the status of your registered
-repositories and their branches. By default branches without changer
-aren't shown, but you can change this behaviour by setting the
-`show-unchanged-branches?' variable in your init file.
-
-The second form prints the location on your filesystem for each
-registered repository as absolute paths."
- (if (and (not (eq? args '())) (equal? (car args) "locations"))
- (list-repository-locations)
- (for-each print repositories)))
-
-(define (list-repository-locations)
- "List the registered locations of repositories."
- (for-each
- (lambda (repo)
- (display (repo-location repo))
- (newline))
- (sort repositories
- (lambda (s1 s2)
- (string<? (repo-location s1) (repo-location s2))))))
-
-(define-command (purge)
- "Purge all registered repositories that can no longer be found."
- "Usage: gitto purge
-
-Go through the list of registered repositories and remove all the ones
-which no longer point to a git repository."
- (set! repositories
- (filter (lambda (repo)
- (file-exists? (repo-location repo)))
- repositories))
- (save-repositories-list))
-
-(define (show-global-config)
- "Show the template specified in `global-config'."
- (write-config global-config))
-
-(define-command (hooks #:optional sub repository)
- "Manage your repositories' hooks."
- "Usage: gitto hooks init [repository]
+(define-command (check repository)
+ "Check to see if a repository has been registered."
+ "Usage: gitto check REPO
-Installs the configured hooks into each repository or the given
-repository."
- (cond
- ((equal? sub "init")
- (let ((hookwrapper
- (lambda (r)
- (unless (member (repo-name r) config-exclusion-list)
- (install-hooks (repo-location r))))))
- (if repository
- (if (known? repository)
- (hookwrapper (make <repository> repository))
- (format #t "Unknown repository: ~a~%" repository))
- (for-each hookwrapper repositories))))))
+Checks whether or not the git repository REPO has been registered with
+gitto."
+ (format #t "Repository is~a registered~%"
+ (if (known? repository) "" " not")))
(define-command (config #:optional sub repository)
"Manage your repositories' configurations."
@@ -235,48 +204,79 @@ destructive operation, you should be mindful."
((equal? sub "global") (show-global-config))
((equal? sub "update") (update-config repository))))
-(define (update-repo-config repo)
- "Merge the configured configuration with REPO's configuration.
+(define-command (hooks #:optional sub repository)
+ "Manage your repositories' hooks."
+ "Usage: gitto hooks init [repository]
-Don't do anything if REPO has been added to `config-exclusion-list'."
- (unless (member (repo-name repo) config-exclusion-list)
- (write-config
- (merge-config (repo-name repo)
- (read-config (repo-location repo))
- global-config)
- (string-append (repo-location repo) "/.git/config"))))
+Installs the configured hooks into each repository or the given
+repository."
+ (cond
+ ((equal? sub "init")
+ (let ((hookwrapper
+ (lambda (r)
+ (unless (member (repo-name r) config-exclusion-list)
+ (install-hooks (repo-location r))))))
+ (if repository
+ (if (known? repository)
+ (hookwrapper (make <repository> repository))
+ (format #t "Unknown repository: ~a~%" repository))
+ (for-each hookwrapper repositories))))))
-(define* (update-config #:optional repo)
- "Merge the configured configuration with all repositories."
- (if repo
- (if (known? repo)
- (update-repo-config (make <repository> repo))
- (format #t "Unknown repository: ~a~%" repo))
- (for-each update-repo-config repositories)))
+(define-command (list . args)
+ "List information about every repository."
+ "Usage: gitto list
+ gitto list locations
-(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))))
+The first form shows an overview of the status of your registered
+repositories and their branches. By default branches without changer
+aren't shown, but you can change this behaviour by setting the
+`show-unchanged-branches?' variable in your init file.
- (let* ((command-spec (cdr (member "gitto" args string-suffix?)))
- (command-specified? (not (eq? command-spec '())))
- (command (car (if command-specified? command-spec '("list")))))
- (if (command? command)
- (apply (command-function command)
- (if command-specified? (cdr command-spec) '()))
- (format #t "Unknown command: ~a~%" (car command-spec))))))
+The second form prints the location on your filesystem for each
+registered repository as absolute paths."
+ (if (and (not (eq? args '())) (equal? (car args) "locations"))
+ (list-repository-locations)
+ (for-each print repositories)))
-(define repositories-file (data-file "repos.scm"))
+(define-command (purge)
+ "Purge all registered repositories that can no longer be found."
+ "Usage: gitto purge
-(define repositories
- (if (file-exists? repositories-file)
- (let* ((port (open-input-file repositories-file))
- (result (read port)))
- (close-port port)
- (map-in-order (lambda (repo) (make <repository> repo)) result))
- '()))
+Go through the list of registered repositories and remove all the ones
+which no longer point to a git repository."
+ (set! repositories
+ (filter (lambda (repo)
+ (file-exists? (repo-location repo)))
+ repositories))
+ (save-repositories-list))
+
+(define-command (remove repository)
+ "Unregister a repository."
+ "Usage: gitto remove REPO
+
+Removes REPO from the registered repository list. This command will
+fail if REPO does not indicate a git repository of if it hasn't been
+registered."
+ (unless (member repository repositories same-repository?)
+ (set! repository (realpath repository)))
+
+ (if (known? repository)
+ (begin
+ (set! repositories
+ (delete repository repositories same-repository?))
+ (save-repositories-list)
+ (simple-format #t "Repository ~A removed." repository))
+ (display "Not a registered repository."))
+ (newline))
+
+(define-command (version)
+ "Display version information."
+ "Usage: gitto version
+
+Displays version and some copyright information."
+ (display "gitto 0.1.0") (newline)
+ (display "Copyright (C) 2012 Tom Willemse") (newline)
+ (display "This program comes with ABSOLUTELY NO WARRANTY.") (newline)
+ (display "You may redistribute copies of this program") (newline)
+ (display "under the terms of the GNU General Public License.") (newline)
+ (display "For more information about these matters, see the file named COPYING.") (newline))