diff options
| author | Fuwn <[email protected]> | 2021-05-20 12:22:38 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-20 12:22:38 +0000 |
| commit | 4b2bcf4a7427ea94ff210dfe686b55755c1f5c3d (patch) | |
| tree | 0bd8b9e97305da383d7a5bf65a3dcbb5dc586aa5 | |
| parent | feat(whirl_prompt): make history builtin more unix like (diff) | |
| download | whirl-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.rs | 4 | ||||
| -rw-r--r-- | whirl_prompt/src/structure.rs | 3 |
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(" ")) } +} |