-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix history command when extra commands are processed (#204)
* Fix history command when extra commands are processed * Unparse next-cmd ast in pipe-cmds * Fix test * Use lein-bullseye container
- Loading branch information
Showing
10 changed files
with
82 additions
and
38 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 |
---|---|---|
|
@@ -77,6 +77,7 @@ | |
|
||
(comment | ||
(start) | ||
(stop) | ||
|
||
(a/active-adapters) | ||
|
||
|
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,28 @@ | ||
(ns yetibot.core.unparser | ||
(:require | ||
[clojure.string :refer [join]] | ||
[instaparse.core :as insta])) | ||
|
||
(defn reconstruct-pipe [cmds] (join " | " cmds)) | ||
|
||
(def unparse-transformer | ||
"Takes a parse tree and turns it back into a string" | ||
(partial | ||
insta/transform | ||
{:words str | ||
:literal str | ||
:space str | ||
:parened str | ||
:cmd identity | ||
;; avoid wrapping the top level :expr in a subexpression when unparsing | ||
:sub-expr str | ||
:expr (fn [& cmds] (str "$(" (reconstruct-pipe cmds) ")")) | ||
})) | ||
|
||
(comment | ||
(unparse-transformer | ||
[[:cmd [:words "grep" [:space " "] "minutes"]]])) | ||
|
||
(defn unparse [parse-tree] | ||
(let [cmds (rest parse-tree) ] | ||
(reconstruct-pipe (unparse-transformer cmds)))) |
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