aboutsummaryrefslogtreecommitdiff
path: root/src/cli/cmd/save.rs
diff options
context:
space:
mode:
authorArne Dußin2021-01-08 15:57:52 +0100
committerArne Dußin2021-01-08 15:57:52 +0100
commit60327dd3ef85a263173e6275cb122c9191c030fe (patch)
tree670c2729ade91daadee62dae37faa828ab70b3f4 /src/cli/cmd/save.rs
parentd8123704ea4fe4f1fb677db31ecac53c9c40096e (diff)
downloadgraf_karto-60327dd3ef85a263173e6275cb122c9191c030fe.tar.gz
graf_karto-60327dd3ef85a263173e6275cb122c9191c030fe.zip
Rename save to write for vim mnemonics compatibility
Diffstat (limited to 'src/cli/cmd/save.rs')
-rw-r--r--src/cli/cmd/save.rs42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/cli/cmd/save.rs b/src/cli/cmd/save.rs
deleted file mode 100644
index 2c022cf..0000000
--- a/src/cli/cmd/save.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-//! Save the contents of the map to disk
-
-use super::Command;
-use super::{CmdParseError, FromArgs};
-use crate::map::MapData;
-use crate::Editor;
-use std::path::PathBuf;
-
-/// The save command can take any destination in the filesystem the user can write to. Processing
-/// will then save the map contents to that destination, overwriting anything that may be there.
-pub struct Save {
- destination: PathBuf,
-}
-
-impl FromArgs for Save {
- fn from_args(args: &[&str]) -> Result<Self, CmdParseError> {
- if args.len() != 1 {
- return Err(CmdParseError::WrongNumberOfArgs(args.len(), 1..=1));
- }
-
- Ok(Self {
- destination: PathBuf::from(args[0]),
- })
- }
-}
-
-impl Command for Save {
- fn process(&self, editor: &mut Editor) -> Result<String, String> {
- let data = MapData::extract_data(editor.map());
-
- match data.write_to_file(&self.destination) {
- Ok(_) => Ok(format!(
- "Successfully wrote contents to `{:?}`",
- &self.destination
- )),
- Err(e) => Err(format!(
- "Unable to write to `{:?}`. Error: {:?}",
- &self.destination, e
- )),
- }
- }
-}