File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
crates/q_cli/src/cli/chat/tools Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11use std:: borrow:: Cow ;
22use std:: io:: Write ;
3+ use std:: path:: PathBuf ;
34
45use crossterm:: queue;
56use crossterm:: style:: {
@@ -8,6 +9,7 @@ use crossterm::style::{
89} ;
910use eyre:: {
1011 Result ,
12+ bail,
1113 eyre,
1214} ;
1315use fig_os_shim:: Context ;
@@ -144,7 +146,19 @@ impl FsWrite {
144146 }
145147
146148 pub async fn validate ( & mut self , _ctx : & Context ) -> Result < ( ) > {
147- // TODO: check to see if paths are valid
149+ match self {
150+ FsWrite :: Create { path, .. } => {
151+ if path. is_empty ( ) {
152+ bail ! ( "Path must not be empty" )
153+ } ;
154+ } ,
155+ FsWrite :: StrReplace { path, .. } | FsWrite :: Insert { path, .. } => {
156+ if !PathBuf :: from ( & path) . exists ( ) {
157+ bail ! ( "The provided path must exist in order to replace or insert contents into it" )
158+ }
159+ } ,
160+ }
161+
148162 Ok ( ( ) )
149163 }
150164}
You can’t perform that action at this time.
0 commit comments