@@ -231,6 +231,8 @@ pub fn create(
231231 label : Option < & str > ,
232232 table_name : Option < & str > ,
233233 file : Option < & str > ,
234+ upload_id : Option < & str > ,
235+ source_format : & str ,
234236) {
235237 let profile_config = match config:: load ( "default" ) {
236238 Ok ( c) => c,
@@ -260,31 +262,42 @@ pub fn create(
260262 . to_string ( ) ;
261263 & label_derived
262264 }
263- None => match stdin_redirect_filename ( ) {
264- Some ( name) => {
265- label_derived = name;
266- & label_derived
267- }
268- None => {
265+ None => {
266+ if upload_id. is_some ( ) {
269267 eprintln ! ( "error: no label provided. Use --label to name the dataset." ) ;
270268 std:: process:: exit ( 1 ) ;
271269 }
272- } ,
270+ match stdin_redirect_filename ( ) {
271+ Some ( name) => {
272+ label_derived = name;
273+ & label_derived
274+ }
275+ None => {
276+ eprintln ! ( "error: no label provided. Use --label to name the dataset." ) ;
277+ std:: process:: exit ( 1 ) ;
278+ }
279+ }
280+ }
273281 } ,
274282 } ;
275283
276284 let client = reqwest:: blocking:: Client :: new ( ) ;
277285
278- let ( upload_id, format) = match file {
279- Some ( path) => upload_from_file ( & client, & api_key, workspace_id, & profile_config. api_url , path) ,
280- None => {
281- use std:: io:: IsTerminal ;
282- if std:: io:: stdin ( ) . is_terminal ( ) {
283- eprintln ! ( "error: no input data. Use --file <path> or pipe data via stdin." ) ;
284- std:: process:: exit ( 1 ) ;
286+ let ( upload_id, format, upload_id_was_uploaded) : ( String , & str , bool ) = if let Some ( id) = upload_id {
287+ ( id. to_string ( ) , source_format, false )
288+ } else {
289+ let ( id, fmt) = match file {
290+ Some ( path) => upload_from_file ( & client, & api_key, workspace_id, & profile_config. api_url , path) ,
291+ None => {
292+ use std:: io:: IsTerminal ;
293+ if std:: io:: stdin ( ) . is_terminal ( ) {
294+ eprintln ! ( "error: no input data. Use --file <path>, --upload-id <id>, or pipe data via stdin." ) ;
295+ std:: process:: exit ( 1 ) ;
296+ }
297+ upload_from_stdin ( & client, & api_key, workspace_id, & profile_config. api_url )
285298 }
286- upload_from_stdin ( & client , & api_key , workspace_id , & profile_config . api_url )
287- }
299+ } ;
300+ ( id , fmt , true )
288301 } ;
289302
290303 let source = json ! ( { "upload_id" : upload_id, "format" : format } ) ;
@@ -312,6 +325,16 @@ pub fn create(
312325 if !resp. status ( ) . is_success ( ) {
313326 use crossterm:: style:: Stylize ;
314327 eprintln ! ( "{}" , api_error( resp. text( ) . unwrap_or_default( ) ) . red( ) ) ;
328+ // Only show the resume hint when the upload_id came from a fresh upload
329+ if upload_id_was_uploaded {
330+ eprintln ! (
331+ "{}" ,
332+ format!(
333+ "Resume dataset creation without re-uploading by passing --upload-id {upload_id}"
334+ )
335+ . yellow( )
336+ ) ;
337+ }
315338 std:: process:: exit ( 1 ) ;
316339 }
317340
0 commit comments