From e44c538f37c48f738dea904cffe4cda67f689914 Mon Sep 17 00:00:00 2001 From: Hasan-Alrimawi <108812045+Hasan-Alrimawi@users.noreply.github.com> Date: Mon, 27 May 2024 16:06:18 +0300 Subject: fix: `--env` flag confusing message on syntax error (#23915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced warning message for --env flag with run and eval subcommands. The commit is specifically made to address issue #23674 by improving the warning messages that appear when using the --env flag with run or eval subcommands in the following scenarios: 1. Missing environment file. 2. Incorrect syntax in the environment file content. **Changes made** - Distinguishes between cases of missing environment file and wrong syntax in the environment file content. - Shows a concise warning message to convey the case/issue occurred. **Code changes & enhancements** - Implemented a match statement to handle different types of errors received while getting and parsing the file content to display a concise warning message, rather than simple error check and then displaying the same warning message for whatever the type of error is. - Updated the related existing tests to reflect the new warning messages. - Added two test cases to cover the wrong environment file content syntax with both run and eval subcommands. **Impact** The use of --env flag with both run/eval would be more user-friendly as it gives a precise description of what is not right when using incorrectly. If you could give it a look, @dsherret , I appreciate your feedback on these changes. --------- Co-authored-by: Bartek IwaƄczuk --- tests/testdata/eval/env_file_missing.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/testdata/eval/env_file_missing.out') diff --git a/tests/testdata/eval/env_file_missing.out b/tests/testdata/eval/env_file_missing.out index 221acab93..2ec371438 100644 --- a/tests/testdata/eval/env_file_missing.out +++ b/tests/testdata/eval/env_file_missing.out @@ -1,2 +1,2 @@ -Warning The `--env` flag was used, but the dotenv file 'missing' was not found. +Warning The `--env` flag was used, but the environment file specified 'missing' was not found. undefined -- cgit v1.2.3