ballerina-lang
ballerina-lang copied to clipboard
[Improvement]: Add directory content validation for `bal clean --target-dir <path>` option
Description
As of now it is possible to delete any directory and its contents using bal clean --target-dir <path>
command. Following is the emitted output for bal clean --help
command,
SYNOPSIS
bal clean [OPTIONS]
DESCRIPTION
Remove the 'target' directory created during the build. This will delete
all files and directories in the target directory.
The default target directory that will be cleaned is the
'<package-root>/target'. You may also provide a custom target to be
cleaned.
OPTIONS
--target-dir <path>
Target directory path.
EXAMPLES
Clean the default target directory of the current package.
$ bal clean
Clean the provided target directory.
$ bal clean <target-directory-path>
Describe your problem(s)
Since the help description says, Remove the 'target' directory created during the build
, the bal clean
command should be limited to ballerina related directories. Some users might mistakenly provide the project directory instead of the target directory for the bal clean --target-dir <path>
and get the project directory deleted.
Describe your solution(s)
It is possible to do a content validation before deleting the provided directory. We can check whether a bin\
directory is present inside the given target directory. If such a directory is not present or if there are unrecognized subdirectories we can halt the deletion and ask for verification in the CLI.
Related area
-> Compilation
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response