aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-20 12:22:38 +0000
committerFuwn <[email protected]>2021-05-20 12:22:38 +0000
commit4b2bcf4a7427ea94ff210dfe686b55755c1f5c3d (patch)
tree0bd8b9e97305da383d7a5bf65a3dcbb5dc586aa5
parentfeat(whirl_prompt): make history builtin more unix like (diff)
downloadwhirl-4b2bcf4a7427ea94ff210dfe686b55755c1f5c3d.tar.xz
whirl-4b2bcf4a7427ea94ff210dfe686b55755c1f5c3d.zip
feat(whirl_config): command struct method which converts field to a command line
-rw-r--r--whirl_prompt/src/lib.rs4
-rw-r--r--whirl_prompt/src/structure.rs3
2 files changed, 4 insertions, 3 deletions
diff --git a/whirl_prompt/src/lib.rs b/whirl_prompt/src/lib.rs
index 900a1a7..32b247f 100644
--- a/whirl_prompt/src/lib.rs
+++ b/whirl_prompt/src/lib.rs
@@ -98,9 +98,7 @@ impl Prompt {
};
if c.keyword != "null" {
- self
- .history
- .push(format!("{} {}", &c.keyword, &c.args.join(" ")));
+ self.history.push(c.to_line());
}
exit_code
diff --git a/whirl_prompt/src/structure.rs b/whirl_prompt/src/structure.rs
index b153cde..4603d37 100644
--- a/whirl_prompt/src/structure.rs
+++ b/whirl_prompt/src/structure.rs
@@ -5,3 +5,6 @@ pub struct Command {
pub keyword: String,
pub args: Vec<String>,
}
+impl Command {
+ pub fn to_line(&self) -> String { format!("{} {}", self.keyword, self.args.join(" ")) }
+}