From dcec8df20ea99c07953f2a0c43cabba2580b6d70 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 12 Aug 2015 08:48:17 -0400 Subject: ui: Add 'list' subcommand. * shroud/ui.scm (%commands): Add "list". * shroud/ui/list.scm: New file. * Makefile.am (SOURCES): Add it. --- Makefile.am | 1 + shroud/ui.scm | 2 +- shroud/ui/list.scm | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 shroud/ui/list.scm 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 +;;; +;;; 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 . + +(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)) -- cgit v1.2.3