-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add command to generate recipe (#192)
* feat: Add command to generate recipe * add changelog * Add yes option * Add yes option * Fake user input * reorder option * fix args * fix docstring
- Loading branch information
Showing
12 changed files
with
165 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (C) 2023 Jen-Chieh Shen | ||
* | ||
* 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 GNU Emacs; see the file COPYING. If not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
exports.command = ['recipe [destination]']; | ||
exports.desc = 'Generate recipe file'; | ||
exports.builder = yargs => yargs | ||
.positional( | ||
'destination', { | ||
description: 'destination path/folder', | ||
alias: 'dest', | ||
type: 'string', | ||
}) | ||
.options({ | ||
'yes': { | ||
description: 'assume the answer to all prompts is yes', | ||
alias: 'y', | ||
type: 'boolean', | ||
group: TITLE_CMD_OPTION, | ||
}, | ||
}); | ||
|
||
exports.handler = async (argv) => { | ||
await UTIL.e_call(argv, 'generate/recipe' | ||
, argv.dest | ||
, UTIL.def_flag(argv.yes, '--yes')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
;;; generate/recipe.el --- Generate recipe file -*- lexical-binding: t; -*- | ||
|
||
;;; Commentary: | ||
;; | ||
;; Command use generate recipe file, | ||
;; | ||
;; $ eask generate recipe [destination] | ||
;; | ||
;; | ||
;; Positional options: | ||
;; | ||
;; [destination] destination path/folder | ||
;; | ||
|
||
;;; 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-load "core/recipe") | ||
|
||
;; | ||
;;; Core | ||
|
||
(eask-start | ||
(if-let ((recipe (eask--recipe-string)) | ||
(name (eask-guess-package-name))) | ||
(let* ((eask-recipe-path (or (eask-args 0) eask-recipe-path)) | ||
(eask-recipe-path (expand-file-name eask-recipe-path)) | ||
(recipe-file (expand-file-name name eask-recipe-path)) | ||
(recipe-string (pp-to-string recipe))) | ||
(when (or (eask-yes-p) | ||
(yes-or-no-p (format "%s\nIs this OK? " recipe-string))) | ||
;; XXX: Just to fake the user input! | ||
(when (eask-yes-p) | ||
(eask-msg (format "%s\nIs this OK? (yes or no) yes" recipe-string))) | ||
(ignore-errors (make-directory eask-recipe-path t)) | ||
(with-current-buffer (find-file recipe-file) | ||
(erase-buffer) | ||
(insert recipe-string) | ||
(save-buffer)) | ||
(eask-info "(Generated in %s)" recipe-file))) | ||
(eask-msg "") | ||
(eask-info "(Repository URL is required to form a recipe)") | ||
(eask-help "core/recipe"))) | ||
|
||
;;; generate/recipe.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters