From 0c829ea8aa33d7575efc40aacedcca72c07a269e Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 20 Dec 2022 15:41:28 +0800 Subject: [PATCH] feature: Adapt `-a`/`--all` option for archives command (#83) * feature: Adapat -a/--all option for archives command * add test * changelog --- CHANGELOG.md | 1 + cmds/core/run.js | 1 - lisp/core/archives.el | 38 +++++++++++++++++++++++++++----------- lisp/core/run.el | 12 ++++++------ test/commands/local/run.sh | 1 + 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index effd0f7a..44d25ef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * Fix void function `eask-source` to `eask-f-source` (#75) * Fix upcoming breaking changes from `package-build` (#65) * Add support for `elisp-lint` (#79) +* Adapt `-a`/`--all` option for archives command (#83) ## 0.7.x > Released Sep 08, 2022 diff --git a/cmds/core/run.js b/cmds/core/run.js index 365ad064..0476ea02 100644 --- a/cmds/core/run.js +++ b/cmds/core/run.js @@ -64,7 +64,6 @@ function startCommand(commands, count) { let command = commands[count]; - console.log(''); console.log('[RUN]: ' + command); let splitted = command.split(' '); diff --git a/lisp/core/archives.el b/lisp/core/archives.el index 332f6d5e..7f9ce76b 100644 --- a/lisp/core/archives.el +++ b/lisp/core/archives.el @@ -27,17 +27,33 @@ (message (concat " %-" eask--length-name "s %-" eask--length-url "s %-" eask--length-priority "s") name url (or priority 0)))) +(defun eask--print-archive-alist (alist) + "Print the archvie ALIST." + (let* ((names (mapcar #'car alist)) + (eask--length-name (format "%s" (eask-seq-str-max names))) + (urls (mapcar #'cdr alist)) + (eask--length-url (format "%s" (eask-seq-str-max urls))) + (priorities (mapcar #'cdr package-archive-priorities)) + (eask--length-priority (format "%s" (eask-seq-str-max priorities)))) + (mapc #'eask--print-archive alist))) + (eask-start - (if package-archives - (progn - (let* ((names (mapcar #'car package-archives)) - (eask--length-name (format "%s" (eask-seq-str-max names))) - (urls (mapcar #'cdr package-archives)) - (eask--length-url (format "%s" (eask-seq-str-max urls))) - (priorities (mapcar #'cdr package-archive-priorities)) - (eask--length-priority (format "%s" (eask-seq-str-max priorities)))) - (mapc #'eask--print-archive package-archives)) - (eask-info "(Total of %s archives)" (length package-archives))) - (eask-info "(No archive has been selected)"))) + (cond + ((eask-all-p) + (eask-info "List all available archives:") + (eask-msg "") + (eask--print-archive-alist eask-source-mapping) + (eask-msg "") + (eask-info "(Total of %s archive%s available)" (length eask-source-mapping) + (eask--sinr eask-source-mapping "" "s"))) + (package-archives + (eask-info "List archives that are currently using:") + (eask-msg "") + (eask--print-archive-alist package-archives) + (eask-msg "") + (eask-info "(Total of %s archive%s listed)" (length package-archives) + (eask--sinr package-archives "" "s"))) + (t + (eask-info "(No archive has been selected)")))) ;;; core/archives.el ends here diff --git a/lisp/core/run.el b/lisp/core/run.el index cb9d7e12..8a0be198 100644 --- a/lisp/core/run.el +++ b/lisp/core/run.el @@ -23,14 +23,14 @@ "Print all available scripts." (eask-msg "available via `eask run-script`") (eask-msg "") - (let* ((keywords (mapcar #'car (reverse eask-scripts))) - (offset (eask-seq-str-max keywords)) + (let* ((keys (mapcar #'car (reverse eask-scripts))) + (offset (eask-seq-str-max keys)) (fmt (concat " %-" (eask-2str offset) "s %s"))) - (dolist (keyword keywords) - (eask-msg fmt keyword (cdr (assoc keyword eask-scripts)))) + (dolist (key keys) + (eask-msg fmt key (cdr (assoc key eask-scripts)))) (eask-msg "") - (eask-info "(Total of %s available script%s)" (length keywords) - (eask--sinr keywords "" "s")))) + (eask-info "(Total of %s available script%s)" (length keys) + (eask--sinr keys "" "s")))) (defun eask--export-command (command) "Export COMMAND instruction." diff --git a/test/commands/local/run.sh b/test/commands/local/run.sh index bcd2bb8a..16feff23 100644 --- a/test/commands/local/run.sh +++ b/test/commands/local/run.sh @@ -34,6 +34,7 @@ cd "./test/mini.emacs.pkg/" echo "Testing local commands..." eask info eask archives +eask archives --all eask list --depth=0 eask concat