From 681af1fb78a735b51dc811aed770b2948212c3fc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 28 May 2021 10:53:49 +0200 Subject: scripts: Commands warn when passed zero arguments. This is a followup to 3f8326237df780404c172ef4127195cc20becd66. * guix/scripts/archive.scm (export-from-store): Warn then FILES is empty. * guix/scripts/build.scm (guix-build): Likewise. * guix/scripts/copy.scm (warn-if-empty): New procedure. (send-to-remote-host, retrieve-from-remote-host): Call it. * guix/scripts/edit.scm (guix-edit): Warn when SPECS is empty. * guix/scripts/environment.scm (guix-environment): Warn when MANIFEST has zero entries. * guix/scripts/graph.scm (guix-graph): Warn then ITEMS is empty. * guix/scripts/package.scm (process-actions): Warn when FILES and TRANS are both empty. --- guix/scripts/copy.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'guix/scripts/copy.scm') diff --git a/guix/scripts/copy.scm b/guix/scripts/copy.scm index 52b476db54..07357af420 100644 --- a/guix/scripts/copy.scm +++ b/guix/scripts/copy.scm @@ -62,6 +62,10 @@ (define tokens (x (leave (G_ "~a: invalid SSH specification~%") spec)))) +(define (warn-if-empty items) + (when (null? items) + (warning (G_ "no arguments specified, nothing to copy~%")))) + (define (send-to-remote-host local target opts) "Send ITEMS to TARGET. ITEMS is a list of store items or package names; for ; package names, build the underlying packages before sending them." @@ -69,6 +73,7 @@ (define (send-to-remote-host local target opts) (ssh-spec->user+host+port target)) ((drv items) (options->derivations+files local opts))) + (warn-if-empty items) (and (build-derivations local drv) (let* ((session (open-ssh-session host #:user user #:port (or port 22))) @@ -94,7 +99,9 @@ (define (retrieve-from-remote-host local source opts) (let*-values (((drv items) (options->derivations+files local opts)) ((retrieved) - (retrieve-files local items remote #:recursive? #t))) + (begin + (warn-if-empty items) + (retrieve-files local items remote #:recursive? #t)))) (close-connection remote) (disconnect! session) (format #t "~{~a~%~}" retrieved) -- cgit v1.2.3