@@ -41,7 +41,8 @@ pub async fn execute(args: RunArgs) -> Result<()> {
4141 . and_then ( |e| e. to_str ( ) )
4242 . unwrap_or ( "http" )
4343 . to_string ( ) ;
44- let dir = abs. parent ( )
44+ let dir = abs
45+ . parent ( )
4546 . unwrap_or_else ( || std:: path:: Path :: new ( "." ) )
4647 . to_path_buf ( ) ;
4748 ( dir, ext)
@@ -59,7 +60,10 @@ pub async fn execute(args: RunArgs) -> Result<()> {
5960 . and_then ( |e| e. to_str ( ) )
6061 . unwrap_or ( "http" )
6162 . to_string ( ) ;
62- let dir = canonical. parent ( ) . context ( "File path resolves to root" ) ?. to_path_buf ( ) ;
63+ let dir = canonical
64+ . parent ( )
65+ . context ( "File path resolves to root" ) ?
66+ . to_path_buf ( ) ;
6367 ( dir, ext)
6468 } ;
6569
@@ -68,7 +72,11 @@ pub async fn execute(args: RunArgs) -> Result<()> {
6872 let env_vars = loop {
6973 let candidate = dir. join ( "env.json" ) ;
7074 if candidate. exists ( ) {
71- let env_file = poste_core:: Environment :: load ( candidate. to_str ( ) . context ( "env.json path is not valid UTF-8" ) ?) ?;
75+ let env_file = poste_core:: Environment :: load (
76+ candidate
77+ . to_str ( )
78+ . context ( "env.json path is not valid UTF-8" ) ?,
79+ ) ?;
7280 let vars = env_file. envs . get ( & args. env ) . cloned ( ) . unwrap_or_default ( ) ;
7381 break vars;
7482 }
@@ -84,8 +92,7 @@ pub async fn execute(args: RunArgs) -> Result<()> {
8492 std:: io:: stdin ( ) . read_to_string ( & mut buf) ?;
8593 buf
8694 } else {
87- let canonical = std:: fs:: canonicalize ( & file_path)
88- . unwrap_or ( file_path. clone ( ) ) ;
95+ let canonical = std:: fs:: canonicalize ( & file_path) . unwrap_or ( file_path. clone ( ) ) ;
8996 std:: fs:: read_to_string ( & canonical) ?
9097 } ;
9198
@@ -94,10 +101,14 @@ pub async fn execute(args: RunArgs) -> Result<()> {
94101 let mut request = parser. parse_at_line ( & content, args. line , & file_ext) ?;
95102
96103 // Resolve connection name for SQL protocols
97- if crate :: util:: is_sql_protocol ( & request. protocol ) && !crate :: util:: is_connection_url ( & request. connection ) && !request. connection . is_empty ( ) {
104+ if crate :: util:: is_sql_protocol ( & request. protocol )
105+ && !crate :: util:: is_connection_url ( & request. connection )
106+ && !request. connection . is_empty ( )
107+ {
98108 let conn_name = request. connection . clone ( ) ;
99109 let conn_store = poste_exec:: sql_connection:: ConnectionStore :: load ( & search_dir) ?;
100- request. connection = conn_store. resolve ( & conn_name, & env_vars)
110+ request. connection = conn_store
111+ . resolve ( & conn_name, & env_vars)
101112 . map_err ( |e| anyhow:: anyhow!( "Failed to resolve connection '{}': {}" , conn_name, e) ) ?;
102113 }
103114
@@ -109,10 +120,14 @@ pub async fn execute(args: RunArgs) -> Result<()> {
109120 }
110121
111122 // Auto-detect protocol from connection URL for .sql files
112- if request. protocol == poste_core:: Protocol :: Postgres && request. connection . starts_with ( "sqlite:" ) {
123+ if request. protocol == poste_core:: Protocol :: Postgres
124+ && request. connection . starts_with ( "sqlite:" )
125+ {
113126 request. protocol = poste_core:: Protocol :: Sqlite ;
114127 }
115- if request. protocol == poste_core:: Protocol :: Postgres && request. connection . starts_with ( "mysql://" ) {
128+ if request. protocol == poste_core:: Protocol :: Postgres
129+ && request. connection . starts_with ( "mysql://" )
130+ {
116131 request. protocol = poste_core:: Protocol :: Mysql ;
117132 }
118133
@@ -141,7 +156,10 @@ pub async fn execute(args: RunArgs) -> Result<()> {
141156 if !response. cookies . is_empty ( ) {
142157 println ! ( "Cookies:" ) ;
143158 for c in & response. cookies {
144- println ! ( " {}={} (domain={}, path={})" , c. name, c. value, c. domain, c. path) ;
159+ println ! (
160+ " {}={} (domain={}, path={})" ,
161+ c. name, c. value, c. domain, c. path
162+ ) ;
145163 }
146164 }
147165 println ! ( "Headers:" ) ;
@@ -165,12 +183,19 @@ pub async fn execute(args: RunArgs) -> Result<()> {
165183}
166184
167185/// Load env vars for variable substitution.
168- pub fn load_env_vars ( search_dir : & std:: path:: Path , env_name : & str ) -> std:: collections:: HashMap < String , String > {
186+ pub fn load_env_vars (
187+ search_dir : & std:: path:: Path ,
188+ env_name : & str ,
189+ ) -> std:: collections:: HashMap < String , String > {
169190 let mut dir = search_dir;
170191 loop {
171192 let candidate = dir. join ( "env.json" ) ;
172193 if candidate. exists ( ) {
173- if let Ok ( env_file) = poste_core:: Environment :: load ( candidate. to_str ( ) . expect ( "env.json path must be valid UTF-8" ) ) {
194+ if let Ok ( env_file) = poste_core:: Environment :: load (
195+ candidate
196+ . to_str ( )
197+ . expect ( "env.json path must be valid UTF-8" ) ,
198+ ) {
174199 if let Some ( vars) = env_file. envs . get ( env_name) {
175200 return vars. clone ( ) ;
176201 }
0 commit comments