(define-module (loadavg ui) #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:use-module (srfi srfi-26) #:use-module (srfi srfi-1) #:use-module (ssh session) #:use-module (ssh auth) #:use-module (ssh popen) #:use-module ((guix ui) #:select (colorize-string)) #:autoload (ice-9 ftw) (scandir) #:use-module ((guix ui) #:select (G_ leave)) #:use-module (loadavg config) #:export (loadavg-main)) (define (show-bug-report-information) ;; TRANSLATORS: The placeholder indicates the bug-reporting address for this ;; package. Please add another line saying "Report translation bugs to ;; ...\n" with the address for translation bugs (typically your translation ;; team's web or email address). (format #t (G_ " Report bugs to: ~a.") %loadavg-bug-report-address) (format #t (G_ " ~a home page: <~a>") %loadavg-package-name %loadavg-home-page-url) (newline)) (define (show-loadavg-usage) (format (current-error-port) "Try `loadavg --help' for more information.~%") (exit 1)) (define (command-files) "Return the list of source files that define LOADAVG sub-commands." (define directory (and=> (search-path %load-path "loadavg.scm") (compose (cut string-append <> "/loadavg/scripts") dirname))) (define dot-scm? (cut string-suffix? ".scm" <>)) (if directory (scandir directory dot-scm?) '())) (define (commands) "Return the list of LOADAVG command names." (map (compose (cut string-drop-right <> 4) basename) (command-files))) (define (show-loadavg-help) (format #t "Usage: loadavg COMMAND ARGS...\nRun COMMAND with ARGS.\n") (newline) (format #t "COMMAND must be one of the sub-commands listed below:\n") (newline) (format #t "~{ ~a~%~}" (sort (commands) stringsymbol command) args)))) (define (loadavg-main arg0 . args) (apply run-loadavg args)) ;;; ;;; main ;;; (define* (main #:optional (args (command-line))) (exit (apply loadavg-main args)))