diff options
author | Kyle Meyer <kyle@kyleam.com> | 2016-04-17 18:27:51 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2016-04-17 19:05:03 -0400 |
commit | 1dccdd134022e8deaf5e0d5db8ff15a090ae26a8 (patch) | |
tree | 282829d07c608cca4a16c9a8d0dd1bb9f5f0bee5 /snakemake.el | |
parent | 4b019984497913a770cf9d29f56f64e8bb5e0673 (diff) | |
download | snakemake-mode-1dccdd134022e8deaf5e0d5db8ff15a090ae26a8.tar.gz |
Add helper for splitting rule lists
Diffstat (limited to 'snakemake.el')
-rw-r--r-- | snakemake.el | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/snakemake.el b/snakemake.el index fa200bd..433fd93 100644 --- a/snakemake.el +++ b/snakemake.el @@ -208,28 +208,31 @@ with DIRECTORY and the Snakefile's modification time." "Call `snakemake-program' with ARGS and insert output." (apply #'call-process snakemake-program nil t nil args)) +(defun snakemake--split-rules (type) + "Return rules of TYPE. +TYPE can be `all' or `target'." + (cl-remove-if + (lambda (x) (string-match-p "\\`[0-9]+\\'" x)) + (split-string + (with-temp-buffer + (if (= 0 (snakemake-insert-output + "--nocolor" + (cl-case type + (all "--list") + (target "--list-target-rules") + (t (user-error "Invalid rule type: %s" type))))) + (buffer-string) + (error "Error finding rules")))))) + (defun snakemake-all-rules (&optional directory) "Return list of rules for DIRECTORY's Snakefile." (snakemake-with-cache directory ("all-rules") - (cl-remove-if - (lambda (x) (string-match-p "\\`[0-9]+\\'" x)) - (split-string - (with-temp-buffer - (if (= 0 (snakemake-insert-output "--nocolor" "--list")) - (buffer-string) - (error "Error finding rules"))))))) + (snakemake--split-rules 'all))) (defun snakemake-rule-targets (&optional directory) "Return list of target rules for DIRECTORY's Snakefile." (snakemake-with-cache directory ("target-rules") - (cl-remove-if - (lambda (x) (string-match-p "\\`[0-9]+\\'" x)) - (split-string - (with-temp-buffer - (if (= 0 (snakemake-insert-output - "--nocolor" "--list-target-rules")) - (buffer-string) - (error "Error finding rule targets"))))))) + (snakemake--split-rules 'target))) (defun snakemake-file-targets (&optional directory) "Return list of output files for DIRECTORY's Snakefile. |