@@ -6,7 +6,7 @@ use crate::ConfigError;
66use anyhow:: anyhow;
77use anyhow:: Context ;
88use anyhow:: Error ;
9- use std :: path :: PathBuf ;
9+ use camino :: Utf8PathBuf ;
1010use tedge_config:: TEdgeConfig ;
1111use tedge_flows:: flow:: Message ;
1212use tedge_flows:: MessageProcessor ;
@@ -19,7 +19,7 @@ pub enum TEdgeFlowsCli {
1919 ///
2020 /// Default to /etc/tedge/flows
2121 #[ clap( long) ]
22- flows_dir : Option < PathBuf > ,
22+ flows_dir : Option < Utf8PathBuf > ,
2323
2424 /// List flows processing messages published on this topic
2525 ///
@@ -34,13 +34,13 @@ pub enum TEdgeFlowsCli {
3434 ///
3535 /// Default to /etc/tedge/flows
3636 #[ clap( long) ]
37- flows_dir : Option < PathBuf > ,
37+ flows_dir : Option < Utf8PathBuf > ,
3838
3939 /// Path to the flow step script or TOML flow definition
4040 ///
4141 /// If none is provided, applies all the matching flows
4242 #[ clap( long) ]
43- flow : Option < PathBuf > ,
43+ flow : Option < Utf8PathBuf > ,
4444
4545 /// Trigger onInterval after all the message samples
4646 #[ clap( long = "final-on-interval" ) ]
@@ -106,25 +106,28 @@ impl BuildCommand for TEdgeFlowsCli {
106106}
107107
108108impl TEdgeFlowsCli {
109- fn default_flows_dir ( config : & TEdgeConfig ) -> PathBuf {
110- config. root_dir ( ) . join ( "flows" ) . into ( )
109+ fn default_flows_dir ( config : & TEdgeConfig ) -> Utf8PathBuf {
110+ config. root_dir ( ) . join ( "flows" )
111111 }
112112
113- pub async fn load_flows ( flows_dir : & PathBuf ) -> Result < MessageProcessor , Error > {
113+ pub async fn load_flows ( flows_dir : & Utf8PathBuf ) -> Result < MessageProcessor , Error > {
114114 MessageProcessor :: try_new ( flows_dir)
115115 . await
116- . with_context ( || format ! ( "loading flows and steps from {}" , flows_dir . display ( ) ) )
116+ . with_context ( || format ! ( "loading flows and steps from {flows_dir}" ) )
117117 }
118118
119- pub async fn load_file ( flows_dir : & PathBuf , path : & PathBuf ) -> Result < MessageProcessor , Error > {
120- if let Some ( "toml" ) = path. extension ( ) . and_then ( |s| s. to_str ( ) ) {
119+ pub async fn load_file (
120+ flows_dir : & Utf8PathBuf ,
121+ path : & Utf8PathBuf ,
122+ ) -> Result < MessageProcessor , Error > {
123+ if let Some ( "toml" ) = path. extension ( ) {
121124 MessageProcessor :: try_new_single_flow ( flows_dir, path)
122125 . await
123- . with_context ( || format ! ( "loading flow {flow}" , flow = path . display ( ) ) )
126+ . with_context ( || format ! ( "loading flow {path}" ) )
124127 } else {
125128 MessageProcessor :: try_new_single_step_flow ( flows_dir, path)
126129 . await
127- . with_context ( || format ! ( "loading flow script {script}" , script = path . display ( ) ) )
130+ . with_context ( || format ! ( "loading flow script {path}" ) )
128131 }
129132 }
130133}
0 commit comments