summaryrefslogtreecommitdiff
path: root/src/cmds/cmd
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-22 21:23:35 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-22 21:23:35 +0800
commit8c1deed6b8cd87a2de04bf92c5cd997c3ccd322b (patch)
tree8ea35003266be9f0928686ca312710b24076000f /src/cmds/cmd
parent09d64357180e0797b8dcdcaf14b4d3a634effc29 (diff)
Handle missing file by returning empty sheet data
Diffstat (limited to 'src/cmds/cmd')
-rw-r--r--src/cmds/cmd/sheetedit.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cmds/cmd/sheetedit.rs b/src/cmds/cmd/sheetedit.rs
index 85cb616..8e3449e 100644
--- a/src/cmds/cmd/sheetedit.rs
+++ b/src/cmds/cmd/sheetedit.rs
@@ -59,9 +59,13 @@ async fn collect(args: &Arg, ctx: &JVCommandContext) -> Result<Collect, CmdPrepa
(_, Some(stdin_path)) => tokio::fs::read(stdin_path)
.await
.map_err(CmdPrepareError::Io)?,
- (Some(file_path), None) => tokio::fs::read(file_path)
- .await
- .map_err(CmdPrepareError::Io)?,
+ (Some(file_path), None) => match tokio::fs::read(file_path).await {
+ Ok(data) => data,
+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
+ SheetData::empty().as_bytes().to_vec()
+ }
+ Err(e) => return Err(CmdPrepareError::Io(e)),
+ },
(None, None) => return early_cmd_output!(JVNoneOutput => JVNoneOutput),
};
Ok(Collect { data })