@@ -32,9 +32,9 @@ use record_format::{
3232use s2_sdk:: {
3333 S2 ,
3434 types:: {
35- AppendRetryPolicy , BasinState , CreateStreamInput , DeleteOnEmptyConfig , DeleteStreamInput ,
36- MeteredBytes , Metric , RetentionPolicy , RetryConfig , StreamConfig as SdkStreamConfig ,
37- StreamName , TimestampingConfig , TimestampingMode ,
35+ AppendRetryPolicy , CreateStreamInput , DeleteOnEmptyConfig , DeleteStreamInput , MeteredBytes ,
36+ Metric , RetentionPolicy , RetryConfig , StreamConfig as SdkStreamConfig , StreamName ,
37+ TimestampingConfig , TimestampingMode ,
3838 } ,
3939} ;
4040use strum:: VariantNames ;
@@ -196,11 +196,10 @@ async fn run() -> Result<(), CliError> {
196196
197197 let ( streams, _) = ops:: list_streams ( & s2, list_streams_args) . await ?;
198198 for stream_info in streams {
199- println ! (
200- "s2://{}/{} {}" ,
201- basin,
202- stream_info. name,
203- stream_info. created_at. to_string( ) . green( ) ,
199+ print_listing_with_created_at (
200+ format ! ( "s2://{}/{}" , basin, stream_info. name) ,
201+ stream_info. created_at . to_string ( ) ,
202+ stream_info. deleted_at . is_some ( ) ,
204203 ) ;
205204 }
206205 } else {
@@ -224,34 +223,21 @@ async fn run() -> Result<(), CliError> {
224223
225224 let ( basins, _) = ops:: list_basins ( & s2, list_basins_args) . await ?;
226225 for basin_info in basins {
227- println ! (
228- "{} {}" ,
229- basin_info. name,
230- format_basin_state( basin_info. state)
231- ) ;
226+ print_listing_uri ( basin_info. name . to_string ( ) , basin_info. deleted_at . is_some ( ) ) ;
232227 }
233228 }
234229 }
235230
236231 Command :: ListBasins ( args) => {
237232 let ( basins, _) = ops:: list_basins ( & s2, args) . await ?;
238233 for basin_info in basins {
239- println ! (
240- "{} {}" ,
241- basin_info. name,
242- format_basin_state( basin_info. state)
243- ) ;
234+ print_listing_uri ( basin_info. name . to_string ( ) , basin_info. deleted_at . is_some ( ) ) ;
244235 }
245236 }
246237
247238 Command :: CreateBasin ( args) => {
248- let info = ops:: create_basin ( & s2, args) . await ?;
249-
250- let message = match info. state {
251- BasinState :: Active => "✓ Basin created" . green ( ) . bold ( ) ,
252- BasinState :: Deleting => "Basin is being deleted" . red ( ) . bold ( ) ,
253- } ;
254- eprintln ! ( "{message}" ) ;
239+ let _info = ops:: create_basin ( & s2, args) . await ?;
240+ eprintln ! ( "{}" , "✓ Basin created" . green( ) . bold( ) ) ;
255241 }
256242
257243 Command :: DeleteBasin { basin } => {
@@ -311,7 +297,10 @@ async fn run() -> Result<(), CliError> {
311297 let basin_name = args. uri . basin . clone ( ) ;
312298 let ( streams, _) = ops:: list_streams ( & s2, args) . await ?;
313299 for stream_info in streams {
314- println ! ( "s2://{}/{}" , basin_name, stream_info. name) ;
300+ print_listing_uri (
301+ format ! ( "s2://{}/{}" , basin_name, stream_info. name) ,
302+ stream_info. deleted_at . is_some ( ) ,
303+ ) ;
315304 }
316305 }
317306
@@ -623,15 +612,40 @@ async fn run() -> Result<(), CliError> {
623612 result. map_err ( |err| err. with_token_source ( token_source) )
624613}
625614
626- fn format_basin_state ( state : BasinState ) -> colored:: ColoredString {
627- match state {
628- BasinState :: Active => "active" . green ( ) ,
629- BasinState :: Deleting => "deleting" . red ( ) ,
615+ fn format_position ( seq_num : u64 , timestamp : u64 ) -> String {
616+ format ! ( "{seq_num} @ {timestamp}" )
617+ }
618+
619+ fn print_listing_uri ( uri : String , is_deleting : bool ) {
620+ let uri = format_listing_uri ( uri, is_deleting) ;
621+ if is_deleting {
622+ println ! ( "{} {}" , uri, deletion_marker( ) ) ;
623+ } else {
624+ println ! ( "{uri}" ) ;
630625 }
631626}
632627
633- fn format_position ( seq_num : u64 , timestamp : u64 ) -> String {
634- format ! ( "{seq_num} @ {timestamp}" )
628+ fn print_listing_with_created_at ( uri : String , created_at : String , is_deleting : bool ) {
629+ let uri = format_listing_uri ( uri, is_deleting) ;
630+ let created_at = if is_deleting {
631+ created_at. red ( )
632+ } else {
633+ created_at. green ( )
634+ } ;
635+
636+ if is_deleting {
637+ println ! ( "{} {} {}" , uri, created_at, deletion_marker( ) ) ;
638+ } else {
639+ println ! ( "{} {}" , uri, created_at) ;
640+ }
641+ }
642+
643+ fn format_listing_uri ( uri : String , is_deleting : bool ) -> colored:: ColoredString {
644+ if is_deleting { uri. red ( ) } else { uri. normal ( ) }
645+ }
646+
647+ fn deletion_marker ( ) -> colored:: ColoredString {
648+ "[deleting]" . red ( ) . bold ( )
635649}
636650
637651async fn write_record (
0 commit comments