diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-08-12 08:48:17 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-08-12 08:48:17 -0400 |
commit | dcec8df20ea99c07953f2a0c43cabba2580b6d70 (patch) | |
tree | 9906476a08b4a67949699ba27f9d9eee435d9681 | |
parent | eb6e3ad5d1612a8ccb2b4ad5e1c1e62187d6f0e9 (diff) |
ui: Add 'list' subcommand.
* shroud/ui.scm (%commands): Add "list".
* shroud/ui/list.scm: New file.
* Makefile.am (SOURCES): Add it.
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | shroud/ui.scm | 2 | ||||
-rw-r--r-- | shroud/ui/list.scm | 55 |
3 files changed, 57 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 557b91c..ec7af0a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,5 +43,6 @@ SOURCES = \ shroud/secret.scm \ shroud/ui.scm \ shroud/ui/hide.scm \ + shroud/ui/list.scm \ shroud/ui/remove.scm \ shroud/ui/show.scm diff --git a/shroud/ui.scm b/shroud/ui.scm index 1656f08..bbe0f2a 100644 --- a/shroud/ui.scm +++ b/shroud/ui.scm @@ -40,7 +40,7 @@ (define program-name (make-parameter "shroud")) (define %commands - '("hide" "show" "remove")) + '("hide" "list" "show" "remove")) (define (show-help) (format #t "Usage: shroud COMMAND ARGS... diff --git a/shroud/ui/list.scm b/shroud/ui/list.scm new file mode 100644 index 0000000..fdf5f10 --- /dev/null +++ b/shroud/ui/list.scm @@ -0,0 +1,55 @@ +;;; Shroud +;;; Copyright © 2015 David Thompson <davet@gnu.org> +;;; +;;; Shroud is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Shroud is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Shroud. If not, see <http://www.gnu.org/licenses/>. + +(define-module (shroud ui list) + #:use-module (ice-9 format) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-37) + #:use-module (shroud utils) + #:use-module (shroud secret) + #:use-module (shroud ui) + #:export (shroud-list)) + +(define (show-help) + (format #t "Usage: shroud list [OPTION] +Show the names of all secrets in the database.~%") + (display " + -h, --help display this help and exit") + (display " + --version display version information and exit") + (newline)) + +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '("version") #f #f + (lambda args + (show-version-and-exit))))) + +(define (shroud-list config db . args) + (let* ((opts (simple-args-fold args %options '())) + (db (force db))) + + (for-each (lambda (secret) + (display (secret-id secret)) + (newline)) + db) + + ;; We don't alter the database. + db)) |