From f92e9f6f07b1e3834c2ca58ce3510734819d08e4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Wed, 27 Jan 2021 14:01:50 +0100 Subject: Rework graf karto to fit the client/server structure --- src/cli/cmd/edit.rs | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/cli/cmd/edit.rs (limited to 'src/cli/cmd/edit.rs') diff --git a/src/cli/cmd/edit.rs b/src/cli/cmd/edit.rs deleted file mode 100644 index b164332..0000000 --- a/src/cli/cmd/edit.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Replace the contents of the currently edited map with contents from a file. - -use super::Command; -use super::{CmdParseError, FromArgs}; -use crate::map::MapData; -use crate::Editor; -use std::path::PathBuf; - -/// Command to load a file from the disk and replace the current editor contents with it's info. -pub struct Edit { - file: PathBuf, -} - -impl FromArgs for Edit { - fn from_args(args: &[&str]) -> Result { - if args.len() != 1 { - return Err(CmdParseError::WrongNumberOfArgs(args.len(), 1..=1)); - } - - Ok(Self { - file: PathBuf::from(args[0]), - }) - } -} - -impl Command for Edit { - fn process(&self, editor: &mut Editor) -> Result { - let data = match MapData::load_from_file(&self.file) { - Ok(data) => data, - Err(err) => { - return Err(format!( - "Unable to read file: {:?}, reason: {:?}", - &self.file, err - )) - } - }; - - editor.map_mut().set_data(data); - Ok(format!("Map data from {:?} loaded.", &self.file)) - } -} -- cgit v1.2.3-70-g09d2