diff --git a/CHANGELOG.md b/CHANGELOG.md index 6100c6ce..1ceb6106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * Add command `commnad` for custom commands (#195) * Merge the two commands `run` and `command` (#196) * Add `melpazoid` command (#202) +* Add `source` command and its subcommands (#203) ## 0.8.x > Released Mar 08, 2023 diff --git a/cmds/core/source.js b/cmds/core/source.js new file mode 100644 index 00000000..7ad46049 --- /dev/null +++ b/cmds/core/source.js @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2023 the Eask authors. + * + * This program 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, or (at your option) + * any later version. + * + * This program 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 this program. If not, see . + */ + +"use strict"; + +exports.command = ['source ']; +exports.desc = UTIL.hide_cmd('Add/Remove source from DSL'); +exports.builder = function (yargs) { + yargs.usage(`${exports.desc} + +Usage: eask source [options..]`) + .commandDir('../source/') + .demandCommand(); + + /* XXX: Configure only in the menu. */ + if (UTIL.cmd_count() == 1) { + yargs.positional( + '', { + description: 'type of the control', + }); + } +} + +exports.handler = async (argv) => {}; diff --git a/cmds/link/delete.js b/cmds/link/delete.js index 0bd5d171..c25c370a 100644 --- a/cmds/link/delete.js +++ b/cmds/link/delete.js @@ -17,7 +17,7 @@ "use strict"; -exports.command = ['delete [names..]']; +exports.command = ['delete [names..]', 'remove [names..]']; exports.desc = 'Delete local linked packages'; exports.builder = yargs => yargs .positional( diff --git a/cmds/source/add.js b/cmds/source/add.js new file mode 100644 index 00000000..256bc8c4 --- /dev/null +++ b/cmds/source/add.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2023 the Eask authors. + * + * This program 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, or (at your option) + * any later version. + * + * This program 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 this program. If not, see . + */ + +"use strict"; + +exports.command = ['add [url]']; +exports.desc = 'Add an archive source'; +exports.builder = yargs => yargs + .positional( + '', { + description: 'name of the archive', + type: 'array', + }) + .positional( + '[url]', { + description: 'link to the archive', + type: 'string', + }); + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'source/add', argv.name, argv.url); +}; diff --git a/cmds/source/delete.js b/cmds/source/delete.js new file mode 100644 index 00000000..1e16b78a --- /dev/null +++ b/cmds/source/delete.js @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2023 the Eask authors. + * + * This program 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, or (at your option) + * any later version. + * + * This program 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 this program. If not, see . + */ + +"use strict"; + +exports.command = ['delete ', 'remove ']; +exports.desc = 'Remove an archive source'; +exports.builder = yargs => yargs + .positional( + '', { + description: 'name of the archive', + type: 'array', + }); + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'source/delete', argv.name); +}; + diff --git a/cmds/source/list.js b/cmds/source/list.js new file mode 100644 index 00000000..51672e29 --- /dev/null +++ b/cmds/source/list.js @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2023 the Eask authors. + * + * This program 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, or (at your option) + * any later version. + * + * This program 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 this program. If not, see . + */ + +"use strict"; + +exports.command = ['list']; +exports.desc = 'List all source information'; + +exports.handler = async (argv) => { + await UTIL.e_call(argv, 'source/list'); +}; + diff --git a/docs/content/en/Getting-Started/Basic-Usage/_index.md b/docs/content/en/Getting-Started/Basic-Usage/_index.md index 785c89d5..ad222eee 100644 --- a/docs/content/en/Getting-Started/Basic-Usage/_index.md +++ b/docs/content/en/Getting-Started/Basic-Usage/_index.md @@ -146,6 +146,7 @@ Here is a list of known nested subcommands: - eask link - eask lint - eask run +- eask source - eask test ## ๐Ÿ“Œ Knowing your `elpa` directory diff --git a/docs/content/en/Getting-Started/Commands-and-options.md b/docs/content/en/Getting-Started/Commands-and-options.md index 9927d142..ef165edf 100644 --- a/docs/content/en/Getting-Started/Commands-and-options.md +++ b/docs/content/en/Getting-Started/Commands-and-options.md @@ -328,12 +328,12 @@ $ eask [GLOBAL-OPTIONS] run script [NAMES..] Run the command. +Alias: `cmd` + ```sh $ eask [GLOBAL-OPTIONS] run command [NAMES..] ``` -Alias: `cmd` - ## ๐Ÿ” eask docker Launch specified Emacs version in a Docker container. @@ -540,6 +540,8 @@ $ eask [GLOBAL-OPTIONS] link add Deletes the link for the given packages. +Alias: `remove` + ```sh $ eask [GLOBAL-OPTIONS] link delete [names..] ``` @@ -558,6 +560,8 @@ $ eask [GLOBAL-OPTIONS] link list Delete `.eask` from the current workspace. +Alias: `.eask` + ```sh $ eask [GLOBAL-OPTIONS] clean workspace ``` @@ -568,8 +572,6 @@ $ eask [GLOBAL-OPTIONS] clean workspace $ eask clean workspace -g ``` -Alias: `.eask` - ## ๐Ÿ” eask clean elc Delete all `.elc` files. This would respect to your `Eask` file. @@ -582,12 +584,12 @@ $ eask [GLOBAL-OPTIONS] clean elc Delete dist subdirectory. +Alias: `distribution` + ```sh $ eask [GLOBAL-OPTIONS] clean dist ``` -Alias: `distribution` - ## ๐Ÿ” eask clean autoloads Remove generated autoloads file. @@ -623,13 +625,13 @@ This command is the combination of all other clean commands. - `clean pkg-file` - `clean log-file` +Alias: `everything` + ```sh $ eask [GLOBAL-OPTIONS] clean all ``` -Alias: `everything` - -# ๐Ÿšฉ Linter +# ๐Ÿšฉ Linting Commands that lint your Emacs package. @@ -711,12 +713,12 @@ $ eask [GLOBAL-OPTIONS] lint declare [FILES..] Run [relint](https://github.com/mattiase/relint). +Alias: `lint relint` + ```sh $ eask [GLOBAL-OPTIONS] lint regexps [FILES..] ``` -Alias: `lint relint` - # ๐Ÿšฉ Testing ## ๐Ÿ” eask test activate @@ -769,6 +771,40 @@ $ eask [GLOBAL-OPTIONS] test melpazoid [DIRECTORIES..] ๐Ÿ’ก If **[DIRECTORIES..]** is not passed in; it will use the current workspace instead. {{< /hint >}} +# ๐Ÿšฉ Control DSL + +List of commands that control DSL. + +## ๐Ÿ” eask source add + +Add an archive source. + +```sh +$ eask [GLOBAL-OPTIONS] source add [URL] +``` + +## ๐Ÿ” eask source delete + +Remove an archive source. + +Alias: `remove` + +```sh +$ eask [GLOBAL-OPTIONS] source delete +``` + +## ๐Ÿ” eask source list + +List all source information. + +```sh +$ eask [GLOBAL-OPTIONS] source list +``` + +{{< hint info >}} +๐Ÿ’ก This command is the same as `$ eask archives`! +{{< /hint >}} + # ๐Ÿšฉ Utilities Other helper commands. diff --git a/docs/content/en/Getting-Started/Introduction.md b/docs/content/en/Getting-Started/Introduction.md index 04a2177a..6476c7f1 100644 --- a/docs/content/en/Getting-Started/Introduction.md +++ b/docs/content/en/Getting-Started/Introduction.md @@ -114,11 +114,11 @@ list. ### ๐Ÿ” Core commands -- [ ] [FEAT] Add `publish` command; to publish package to eask archive? +- [ ] [FEAT] Add `publish` command; to publish the package to the eask archive? ### ๐Ÿ” Eask-file commands -- [ ] [FEAT] Add `add-source` command +- N/A ## ๐Ÿ“‚ Underlying Projects diff --git a/docs/content/zh-TW/Getting-Started/Basic-Usage/_index.md b/docs/content/zh-TW/Getting-Started/Basic-Usage/_index.md index 0a6a0e69..fca68134 100644 --- a/docs/content/zh-TW/Getting-Started/Basic-Usage/_index.md +++ b/docs/content/zh-TW/Getting-Started/Basic-Usage/_index.md @@ -141,6 +141,7 @@ Positionals: - eask link - eask lint - eask run +- eask source - eask test ## ๐Ÿ“Œ ไบ†่งฃไฝ ็š„ `elpa` ็›ฎ้Œ„ diff --git a/docs/content/zh-TW/Getting-Started/Commands-and-options.md b/docs/content/zh-TW/Getting-Started/Commands-and-options.md index 766efbbb..515f57a8 100644 --- a/docs/content/zh-TW/Getting-Started/Commands-and-options.md +++ b/docs/content/zh-TW/Getting-Started/Commands-and-options.md @@ -324,12 +324,12 @@ $ eask [GLOBAL-OPTIONS] run script [NAMES..] ้‹่กŒๆŒ‡ไปคใ€‚ +ๅˆฅๅ: `cmd` + ```sh $ eask [GLOBAL-OPTIONS] run command [NAMES..] ``` -ๅˆฅๅ: `cmd` - ## ๐Ÿ” eask docker ๅœจ Docker ๅฎนๅ™จไธญๅ•Ÿๅ‹•ๆŒ‡ๅฎš็š„ Emacs ็‰ˆๆœฌ @@ -352,7 +352,7 @@ $ eask docker 26.1 info ## ๐Ÿ” eask archives -ๅˆ—ๅ‡บๆ‰€ๆœ‰ๅŒ…ๆช”ๆกˆใ€‚ +ๅˆ—ๅ‡บๆ‰€ๆœ‰ๅŒ…ๆบใ€‚ ```sh $ eask [GLOBAL-OPTIONS] archives @@ -360,7 +360,7 @@ $ eask [GLOBAL-OPTIONS] archives ## ๐Ÿ” eask search -ๅพžๆช”ๆกˆไธญๆœ็ดขๅŒ…ใ€‚ +ๅพžๅŒ…ๆบไธญๆœ็ดขๅŒ…ใ€‚ ```sh $ eask [GLOBAL-OPTIONS] search [QUEIRES..] @@ -392,7 +392,7 @@ $ eask [GLOBAL-OPTIONS] outdated [--depth] ## ๐Ÿ” eask refresh -ๅˆทๆ–ฐๅŒ… archivesใ€‚ +ๅˆทๆ–ฐๅŒ…ๆบใ€‚ ```sh $ eask [GLOBAL-OPTIONS] refresh @@ -527,6 +527,8 @@ $ eask [GLOBAL-OPTIONS] link add ๅˆช้™ค็ตฆๅฎšๅŒ…็š„้ˆๆŽฅใ€‚ +ๅˆฅๅ: `remove` + ```sh $ eask [GLOBAL-OPTIONS] link delete [names..] ``` @@ -545,19 +547,18 @@ $ eask [GLOBAL-OPTIONS] link list ๅพž็•ถๅ‰ๅทฅไฝœๅ€ไธญๅˆช้™ค `.eask` ใ€‚ +ๅˆฅๅ: `.eask` + ```sh $ eask [GLOBAL-OPTIONS] clean workspace ``` โ›”๏ธ ไธ่ฆๆŒ‡ๅฎš้ธ้ … `--config, -c`๏ผŒๅฆๅ‰‡ๅฎƒๆœƒๅˆช้™คไฝ ็š„ๆ•ดๅ€‹ `~/.emacs.d`ใ€‚ - ```elisp $ eask clean workspace -g ``` -ๅˆฅๅ: `.eask` - ## ๐Ÿ” eask clean elc ๅˆช้™คๆ‰€ๆœ‰ `.elc` ๆ–‡ไปถใ€‚ ้€™ๅฐ‡ๅฐŠ้‡ๆ‚จ็š„ `Eask` ๆ–‡ไปถใ€‚ @@ -570,12 +571,12 @@ $ eask [GLOBAL-OPTIONS] clean elc ๅˆช้™ค dist ๅญ็›ฎ้Œ„ใ€‚ +ๅˆฅๅ: `distribution` + ```sh $ eask [GLOBAL-OPTIONS] clean dist ``` -ๅˆฅๅ: `distribution` - ## ๐Ÿ” eask clean autoloads ๅˆช้™ค็”Ÿๆˆ็š„ autoload ๆ–‡ไปถใ€‚ @@ -611,13 +612,13 @@ $ eask [GLOBAL-OPTIONS] clean log-file - `clean pkg-file` - `clean log-file` +ๅˆฅๅ: `everything` + ```sh $ eask [GLOBAL-OPTIONS] clean all ``` -ๅˆฅๅ: `everything` - -# ๐Ÿšฉ ๆฃ€ๆŸฅๅ™จ +# ๐Ÿšฉ ๆฃ€ๆŸฅ ๅฐ Emacs ๅŒ…้€ฒ่กŒ lint ็š„ๅ‘ฝไปคใ€‚ @@ -699,12 +700,12 @@ $ eask [GLOBAL-OPTIONS] lint declare [FILES..] Run [relint](https://github.com/mattiase/relint). +ๅˆฅๅ: `lint relint` + ```sh $ eask [GLOBAL-OPTIONS] lint regexps [FILES..] ``` -ๅˆฅๅ: `lint relint` - # ๐Ÿšฉ ๆธฌ่ฉฆๆก†ๆžถ ## ๐Ÿ” eask test activate @@ -757,6 +758,40 @@ $ eask [GLOBAL-OPTIONS] test melpazoid [DIRECTORIES..] ๐Ÿ’ก ๅฆ‚ๆžœๆœชๅ‚ณๅ…ฅ **[DIRECTORIES..]**๏ผŒๅฎƒๅฐ‡ไฝฟ็”จ็›ฎๅ‰ๅทฅไฝœ็ฉบ้–“ใ€‚ {{< /hint >}} +# ๐Ÿšฉ ๆŽงๅˆถ DSL + +ๆŽงๅˆถ DSL ็š„ๆŒ‡ไปคๅˆ—่กจใ€‚ + +## ๐Ÿ” eask source add + +ๆ–ฐๅขžไธ€ๅ€‹ๅŒ…ๆบใ€‚ + +```sh +$ eask [GLOBAL-OPTIONS] source add [URL] +``` + +## ๐Ÿ” eask source delete + +็งป้™คไธ€ๅ€‹ๅŒ…ๆบใ€‚ + +ๅˆฅๅ: `remove` + +```sh +$ eask [GLOBAL-OPTIONS] source delete +``` + +## ๐Ÿ” eask source list + +ๅˆ—ๅ‡บๆ‰€ๆœ‰ๅŒ…ๆบใ€‚ + +```sh +$ eask [GLOBAL-OPTIONS] source list +``` + +{{< hint info >}} +๐Ÿ’ก ๆŒ‡ไปค่ˆ‡ `$ eask archives` ็›ธๅŒ! +{{< /hint >}} + # ๐Ÿšฉ ๅฏฆ็”จๅทฅๅ…ท ๅ…ถไป–่ผ”ๅŠฉๅ‘ฝไปคใ€‚ diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 42a4cd65..3807a3e1 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -1118,6 +1118,20 @@ This uses function `locate-dominating-file' to look up directory tree." (nongnu-devel . "https://elpa.nongnu.org/nongnu-devel/")) "Mapping of source name and url.") +(defun eask-2url (url) + "Convert secure/insecure URL." + (if (and url + (gnutls-available-p) + (eask-network-insecure-p)) + (eask-s-replace "https://" "http://" url) + url)) + +(defun eask-source-url (name &optional location) + "Get the source url by it's NAME and LOCATION." + (setq location (or location (cdr (assq (intern (eask-2str name)) eask-source-mapping))) + location (eask-2url location)) + location) + (defvar eask-package nil) (defvar eask-package-desc nil) ; package descriptor (defvar eask-package-descriptor nil) @@ -1299,12 +1313,8 @@ argument COMMAND." (when (symbolp name) (setq name (eask-2str name))) ; ensure to string, accept symbol (when (assoc name package-archives) (eask-error "Multiple definition of source `%s'" name)) - (setq location (or location (cdr (assq (intern name) eask-source-mapping)))) + (setq location (eask-source-url name location)) (unless location (eask-error "Unknown package archive `%s'" name)) - (when (and location - (gnutls-available-p) - (not (eask-network-insecure-p))) - (setq location (eask-s-replace "https://" "http://" location))) (add-to-list 'package-archives (cons name location) t)) (defun eask-f-source-priority (archive-id &optional priority) diff --git a/lisp/core/archives.el b/lisp/core/archives.el index 2aeeda74..6a36dcb5 100644 --- a/lisp/core/archives.el +++ b/lisp/core/archives.el @@ -25,7 +25,7 @@ (priority (assoc name package-archive-priorities)) (priority (cdr priority))) (message (concat " %-" eask--length-name "s %-" eask--length-url "s %-" eask--length-priority "s") - name url (or priority 0)))) + name (eask-2url url) (or priority 0)))) (defun eask--print-archive-alist (alist) "Print the archvie ALIST." diff --git a/lisp/help/source/add b/lisp/help/source/add new file mode 100644 index 00000000..bd897e92 --- /dev/null +++ b/lisp/help/source/add @@ -0,0 +1,7 @@ + +๐Ÿ’ก The given source name is not found in our database. You have following options: + +Options are, + + - [ ] Pass in one extra argument to specify an `[url]` + - [ ] Edit variable `eask-source-mapping` and create a pull request to https://github.com/emacs-eask/cli diff --git a/lisp/help/source/delete b/lisp/help/source/delete new file mode 100644 index 00000000..58ad8f0b --- /dev/null +++ b/lisp/help/source/delete @@ -0,0 +1,4 @@ + +๐Ÿ’ก The given source name is not found in your Eask-file. List all the archives with: + + $ eask source list diff --git a/lisp/source/add.el b/lisp/source/add.el new file mode 100644 index 00000000..4ac55bdd --- /dev/null +++ b/lisp/source/add.el @@ -0,0 +1,120 @@ +;;; source/add.el --- Add an archive source -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Commmand use to add an archive source +;; +;; $ eask source add +;; +;; +;; Positionals: +;; +;; name of the archive +;; link to the archive +;; + +;;; Code: + +(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args))))) + (load (expand-file-name "_prepare.el" + (locate-dominating-file dir "_prepare.el")) + nil t)) + +(defun eask--source-from-mapping (name url) + "Return t if NAME and URL matched our database." + (string= (eask-source-url name) url)) + +(defun eask--source-add (name url exists) + "Add an archive source by NAME. + +If argument URL is nil; ignore the insertion. + +Arguments EXISTS is used to print the information." + (let* ((style-sym (string-match "([ \t\n\r]*source[ \t\n\r]*[']+" (buffer-string))) + (name-str (if style-sym (concat "'" name) + (concat "\"" name "\""))) + (built-in (eask--source-from-mapping name url))) + (if (and url (not built-in)) + (insert "(source " name-str " \"" url "\")\n") + (insert "(source " name-str ")\n")) + (eask-info "(New source `%s' added and points to `%s')" name (or url (cdr exists))))) + +(defun eask--source-write (name url exists) + "Write source construct by NAME and URL. + +The argument URL can be nil. + +The argument EXISTS is use to search for correct position to insert new source." + (with-current-buffer (find-file eask-file) + (goto-char (point-min)) + (cond + (exists + (if (re-search-forward (concat "([ \t\n\r]*source[ \t\n\r]*['\"]+" name) nil t) + (let ((start (point)) + (built-in (eask--source-from-mapping name url))) + (when (string= "\"" (string (char-after))) + (cl-incf start)) + (re-search-forward "[ \t\r\n\")]*" nil t) ; Forward to non-space characters! + (forward-char -1) + (when (string= "\n" (string (char-after))) + (forward-char -1)) + (pcase (string (char-after)) + (")" + (unless built-in + (insert " \"" url "\""))) + ("\"" + (if built-in + (delete-region start (save-window-excursion + (search-forward ")" nil t) + (1- (point)))) + (let ((old (thing-at-point 'string)) + (new (concat "\"" url "\""))) + (delete-region (point) (+ (point) (length old))) + (insert new))))) + (eask-info "(Changed archive `%s''s location from `%s' to `%s')" + name (cdr exists) url)) + (goto-char (point-max)) + (eask--source-add name url exists))) + (t + (if (re-search-forward "([ \t\n\r]*source[ \t\n\r]*['\"]+" nil t) + (forward-paragraph) + (goto-char (point-max))) + (eask--source-add name url exists))) + (save-buffer))) + +(defun eask--source-ask-if-overwrite (name url) + "Ask source overwrite if needed. + +Arguments NAME and URL are main arguments for this command." + (if-let ((exists (assoc name package-archives)) + (old-url (cdr exists))) + (cond ((string= old-url url) + (eask-info "(Nothing has changed due to the URLs are the same)")) + ((yes-or-no-p + (format + (concat + "The archive `%s' is already exists and currently points to `%s'. + +Do you want to overwrite it? ") + name old-url)) + (eask--source-write name url exists)) + (t + (eask-info "(Nothing has changed, aborted)"))) + (eask--source-write name url nil))) + +(eask-start + (let* ((args (eask-args)) + (name (nth 0 args)) + (url (nth 1 args))) + (cond + (url (eask--source-ask-if-overwrite name url)) + (t + (if-let* ((archive (assoc (eask-intern name) eask-source-mapping)) + (name (car archive)) + (name (eask-2str name)) + (url (eask-source-url name))) ; Use the URL from our database! + (eask--source-ask-if-overwrite name url) + (eask-info "(Invalid source name, `%s')" name) + (eask-help "source/add")))))) + +;;; source/add.el ends here diff --git a/lisp/source/delete.el b/lisp/source/delete.el new file mode 100644 index 00000000..67173d21 --- /dev/null +++ b/lisp/source/delete.el @@ -0,0 +1,39 @@ +;;; source/delete.el --- Remove an archive source -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Commmand use to remove an archive source +;; +;; $ eask source delete +;; +;; +;; Positionals: +;; +;; name of the archive +;; + +;;; Code: + +(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args))))) + (load (expand-file-name "_prepare.el" + (locate-dominating-file dir "_prepare.el")) + nil t)) + +(defun eask--source-delete (name) + "Delete an archive source by NAME." + (with-current-buffer (find-file eask-file) + (goto-char (point-min)) + (when (re-search-forward (concat "([ \t\n\r]*source[ \t\n\r]*['\"]+" name) nil t) + (delete-region (line-beginning-position) (1+ (line-end-position))) + (eask-info "(Delete source `%s')" name)) + (save-buffer))) + +(eask-start + (let* ((args (eask-args)) + (name (nth 0 args))) + (if-let ((exists (assoc name package-archives))) + (eask--source-delete name) + (eask-info "(Invalid source name, `%s')" name) + (eask-help "source/delete")))) + +;;; source/delete.el ends here diff --git a/lisp/source/list.el b/lisp/source/list.el new file mode 100644 index 00000000..7d645dbc --- /dev/null +++ b/lisp/source/list.el @@ -0,0 +1,20 @@ +;;; source/list.el --- List all source information -*- lexical-binding: t; -*- + +;;; Commentary: +;; +;; Commmand use to list all source information +;; +;; $ eask source list +;; + +;;; Code: + +(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args))))) + (load (expand-file-name "_prepare.el" + (locate-dominating-file dir "_prepare.el")) + nil t)) + +(eask-start + (eask-call "core/archives")) + +;;; source/list.el ends here diff --git a/src/util.js b/src/util.js index 280b8ada..0f08bb4d 100644 --- a/src/util.js +++ b/src/util.js @@ -236,15 +236,6 @@ async function e_call(argv, script, ...args) { }); } -/** - * Hide command unless options `--show-hidden` is specified. - * @param { string | boolean } description - to display when comand is showed, - * @return Return a string to show command, else we return false. - */ -function hide_cmd(description) { - return (process.argv.includes('--show-hidden')) ? description : false; -} - /** * Get the command count, not including options. * @return Return a size of the command array. @@ -255,6 +246,18 @@ function cmd_count() { return args.length; } +/** + * Hide command unless options `--show-hidden` is specified. + * @param { string | boolean } description - to display when comand is showed, + * @return Return a string to show command, else we return false. + */ +function hide_cmd(description) { + if ((process.argv.includes('--show-hidden')) + || 1 <= cmd_count()) // When display in submenu! + return description; + return false; +} + /* * Module Exports diff --git a/test/commands/local/run.sh b/test/commands/local/run.sh index 9fdf3226..a253d2ee 100644 --- a/test/commands/local/run.sh +++ b/test/commands/local/run.sh @@ -71,7 +71,7 @@ eask generate recipe -y #eask generate license gpl-3.0 # XXX: Avoid API rate limit exceeded error eask generate ignore elisp -# Linter +# Linting eask lint checkdoc eask lint declare eask lint elint @@ -86,7 +86,7 @@ eask lint regexps # Testing eask test activate -# Clean up +# Cleaning eask clean .eask eask clean elc eask clean dist @@ -95,6 +95,11 @@ eask clean pkg-file eask clean log-file eask clean all +# Control DSL +eask source add test "https://test.elpa.com" +eask source delete test +eask source list + # Util eask locate eask upgrade-eask