Skip to main content

excel_cli/actions/
sheet.rs

1use super::{ActionType, Command};
2use crate::excel::Sheet;
3use anyhow::Result;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum SheetOperation {
7    Create,
8    Delete,
9}
10
11#[derive(Clone)]
12pub struct SheetAction {
13    pub sheet_index: usize,
14    pub sheet_name: String,
15    pub sheet_data: Sheet,
16    pub column_widths: Vec<usize>,
17    pub operation: SheetOperation,
18}
19
20impl Command for SheetAction {
21    fn execute(&self) -> Result<()> {
22        unimplemented!("Requires an ActionExecutor implementation")
23    }
24
25    fn undo(&self) -> Result<()> {
26        unimplemented!("Requires an ActionExecutor implementation")
27    }
28
29    fn action_type(&self) -> ActionType {
30        match self.operation {
31            SheetOperation::Create => ActionType::CreateSheet,
32            SheetOperation::Delete => ActionType::DeleteSheet,
33        }
34    }
35}