@@ -167,7 +167,10 @@ impl std::fmt::Display for BuildStatus {
167167impl BuildStatus {
168168 /// Returns true if this is a terminal state (no more transitions expected)
169169 pub fn is_terminal ( & self ) -> bool {
170- matches ! ( self , BuildStatus :: Completed | BuildStatus :: Failed | BuildStatus :: Cancelled )
170+ matches ! (
171+ self ,
172+ BuildStatus :: Completed | BuildStatus :: Failed | BuildStatus :: Cancelled
173+ )
171174 }
172175}
173176
@@ -279,8 +282,8 @@ pub struct StopDeploymentResponse {
279282
280283impl ApiClient {
281284 pub fn new ( ) -> Result < Self > {
282- let base_url = std :: env :: var ( "HYPERSTACK_API_URL" )
283- . unwrap_or_else ( |_| DEFAULT_API_URL . to_string ( ) ) ;
285+ let base_url =
286+ std :: env :: var ( "HYPERSTACK_API_URL" ) . unwrap_or_else ( |_| DEFAULT_API_URL . to_string ( ) ) ;
284287
285288 let api_key = Self :: load_api_key ( ) . ok ( ) ;
286289
@@ -522,7 +525,12 @@ impl ApiClient {
522525 }
523526
524527 /// List builds for the authenticated user, optionally filtered by spec_id
525- pub fn list_builds_filtered ( & self , limit : Option < i64 > , offset : Option < i64 > , spec_id : Option < i32 > ) -> Result < Vec < Build > > {
528+ pub fn list_builds_filtered (
529+ & self ,
530+ limit : Option < i64 > ,
531+ offset : Option < i64 > ,
532+ spec_id : Option < i32 > ,
533+ ) -> Result < Vec < Build > > {
526534 let api_key = self . require_api_key ( ) ?;
527535
528536 let mut url = format ! ( "{}/api/builds" , self . base_url) ;
@@ -591,7 +599,10 @@ impl ApiClient {
591599
592600 let response = self
593601 . client
594- . get ( format ! ( "{}/api/deployments/{}" , self . base_url, deployment_id) )
602+ . get ( format ! (
603+ "{}/api/deployments/{}" ,
604+ self . base_url, deployment_id
605+ ) )
595606 . bearer_auth ( api_key)
596607 . send ( )
597608 . context ( "Failed to send get deployment request" ) ?;
@@ -606,7 +617,10 @@ impl ApiClient {
606617
607618 let response = self
608619 . client
609- . delete ( format ! ( "{}/api/deployments/{}" , self . base_url, deployment_id) )
620+ . delete ( format ! (
621+ "{}/api/deployments/{}" ,
622+ self . base_url, deployment_id
623+ ) )
610624 . bearer_auth ( api_key)
611625 . send ( )
612626 . context ( "Failed to send stop deployment request" ) ?;
@@ -626,39 +640,34 @@ impl ApiClient {
626640 response : reqwest:: blocking:: Response ,
627641 ) -> Result < T > {
628642 if response. status ( ) . is_success ( ) {
629- response
630- . json ( )
631- . context ( "Failed to parse response JSON" )
643+ response. json ( ) . context ( "Failed to parse response JSON" )
632644 } else {
633645 let status = response. status ( ) ;
634- let error: ErrorResponse = response
635- . json ( )
636- . unwrap_or_else ( |_| ErrorResponse {
637- error : "Unknown error" . to_string ( ) ,
638- } ) ;
646+ let error: ErrorResponse = response. json ( ) . unwrap_or_else ( |_| ErrorResponse {
647+ error : "Unknown error" . to_string ( ) ,
648+ } ) ;
639649 anyhow:: bail!( "API error ({}): {}" , status, error. error) ;
640650 }
641651 }
642652
643653 // Credentials management
644654
645655 fn credentials_path ( ) -> Result < PathBuf > {
646- let home = dirs :: home_dir ( )
647- . ok_or_else ( || anyhow:: anyhow!( "Could not find home directory" ) ) ?;
656+ let home =
657+ dirs :: home_dir ( ) . ok_or_else ( || anyhow:: anyhow!( "Could not find home directory" ) ) ?;
648658 Ok ( home. join ( ".hyperstack" ) . join ( "credentials.toml" ) )
649659 }
650660
651661 pub fn save_api_key ( api_key : & str ) -> Result < ( ) > {
652662 let path = Self :: credentials_path ( ) ?;
653-
663+
654664 // Create directory if it doesn't exist
655665 if let Some ( parent) = path. parent ( ) {
656666 fs:: create_dir_all ( parent) ?;
657667 }
658668
659669 let content = format ! ( "api_key = \" {}\" \n " , api_key) ;
660- fs:: write ( & path, content)
661- . context ( "Failed to save API key" ) ?;
670+ fs:: write ( & path, content) . context ( "Failed to save API key" ) ?;
662671
663672 Ok ( ( ) )
664673 }
@@ -673,19 +682,17 @@ impl ApiClient {
673682 api_key : String ,
674683 }
675684
676- let creds: Credentials = toml :: from_str ( & content )
677- . context ( "Failed to parse credentials file" ) ?;
685+ let creds: Credentials =
686+ toml :: from_str ( & content ) . context ( "Failed to parse credentials file" ) ?;
678687
679688 Ok ( creds. api_key )
680689 }
681690
682691 pub fn delete_api_key ( ) -> Result < ( ) > {
683692 let path = Self :: credentials_path ( ) ?;
684693 if path. exists ( ) {
685- fs:: remove_file ( & path)
686- . context ( "Failed to delete credentials file" ) ?;
694+ fs:: remove_file ( & path) . context ( "Failed to delete credentials file" ) ?;
687695 }
688696 Ok ( ( ) )
689697 }
690698}
691-
0 commit comments