@@ -367,11 +367,17 @@ pub fn parse_input_to_json(value: &str) -> String {
367
367
pub fn get_input ( input : & Option < String > , stdin : & Option < String > , path : & Option < String > ) -> String {
368
368
let value = match ( input, stdin, path) {
369
369
( Some ( _) , Some ( _) , None ) | ( None , Some ( _) , Some ( _) ) => {
370
- error ! ( "Error: Cannot specify both stdin and --input or --path" ) ;
370
+ error ! ( "Error: Cannot specify both stdin and --document or --path" ) ;
371
371
exit ( EXIT_INVALID_ARGS ) ;
372
372
} ,
373
373
( Some ( input) , None , None ) => {
374
374
debug ! ( "Reading input from command line parameter" ) ;
375
+
376
+ // see if user accidentally passed in a file path
377
+ if Path :: new ( input) . exists ( ) {
378
+ error ! ( "Error: Document provided is a file path, use --path instead" ) ;
379
+ exit ( EXIT_INVALID_INPUT ) ;
380
+ }
375
381
input. clone ( )
376
382
} ,
377
383
( None , Some ( stdin) , None ) => {
@@ -413,7 +419,7 @@ pub fn get_input(input: &Option<String>, stdin: &Option<String>, path: &Option<S
413
419
///
414
420
/// # Arguments
415
421
///
416
- /// * `config_path` - Full path to the config file
422
+ /// * `config_path` - Full path to the config file
417
423
///
418
424
/// # Returns
419
425
///
@@ -428,14 +434,14 @@ pub fn set_dscconfigroot(config_path: &str) -> String
428
434
exit ( EXIT_DSC_ERROR ) ;
429
435
} ;
430
436
431
- let Some ( config_root_path) = full_path. parent ( ) else {
437
+ let Some ( config_root_path) = full_path. parent ( ) else {
432
438
// this should never happen because path was absolutized
433
439
error ! ( "Error reading config path parent" ) ;
434
440
exit ( EXIT_DSC_ERROR ) ;
435
441
} ;
436
442
437
443
let env_var = "DSC_CONFIG_ROOT" ;
438
-
444
+
439
445
// warn if env var is already set/used
440
446
if env:: var ( env_var) . is_ok ( ) {
441
447
warn ! ( "The current value of '{env_var}' env var will be overridden" ) ;
0 commit comments