diff options
| author | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2015-02-22 19:39:05 +0300 |
|---|---|---|
| committer | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2015-02-22 19:39:48 +0300 |
| commit | ef099a111094fdbd1d474ac670a0f924452ee357 (patch) | |
| tree | 8c21a9a97de3b79f63fe300b67744a1861a2501c /examples/echo | |
| parent | README (Requirements): Require libssh 0.6.3 or 0.6.4 (diff) | |
| download | guile-ssh-ef099a111094fdbd1d474ac670a0f924452ee357.tar.gz | |
examples/echo/client.scm.in (print-help): Rename
* examples/echo/client.scm.in (print-help): Rename to
`print-help-and-exit'.
(main): Use it. Remove extra checks.
Diffstat (limited to 'examples/echo')
| -rw-r--r-- | examples/echo/client.scm.in | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/examples/echo/client.scm.in b/examples/echo/client.scm.in index 536a0f2..761e016 100644 --- a/examples/echo/client.scm.in +++ b/examples/echo/client.scm.in @@ -5,7 +5,7 @@ ;;; client.scm -- Echo client example. -;; Copyright (C) 2014 Artyom V. Poptsov <poptsov.artyom@gmail.com> +;; Copyright (C) 2014, 2015 Artyom V. Poptsov <poptsov.artyom@gmail.com> ;; ;; This program is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -60,7 +60,7 @@ (help (single-char #\h) (value #f)))) -(define (print-help) +(define (print-help-and-exit) "Print information about program usage." (display (string-append "\ " *program-name* " -- Echo client example. @@ -74,7 +74,8 @@ Options: --user=<user>, -u <user> User name --port=<port-number>, -p <port-number> Port number --identity-file=<file>, -i <file> Path to private key -"))) +")) + (exit 0)) (define (handle-error session) "Handle a SSH error." @@ -100,11 +101,6 @@ Options: (define (main args) "Entry point of the program." - (if (null? (cdr args)) - (begin - (print-help) - (exit 0))) - (let* ((options (getopt-long args *option-spec*)) (user (option-ref options 'user *default-user*)) (port (option-ref options 'port *default-port*)) @@ -113,15 +109,11 @@ Options: (help-needed? (option-ref options 'help #f)) (args (option-ref options '() #f))) - (if help-needed? - (begin - (print-help) - (exit 0))) + (and (null? args) + (print-help-and-exit)) - (if (or (null? args) (null? (cdr args))) - (begin - (print-help) - (exit 0))) + (and help-needed? + (print-help-and-exit)) (let* ((host (car args)) (str (cadr args)) |
