Adding "--force" flag to some commands (#1)

* Adding "--force" flag to "drop" command

* Adding "--force" flag to "import" command
This commit is contained in:
Marco Lipparini
2023-07-18 19:41:39 +02:00
committed by GitHub
parent 0fc09fb3c7
commit e8ce789943
2 changed files with 17 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
name: Lint
on: [push, pull_request]
on: [pull_request]
jobs:
lint:

View File

@@ -127,14 +127,17 @@ program
.command('drop')
.description('Drops the given database and its default user (if they exist)')
.argument('<db_name>', 'The database name')
.action(async (databaseName) => {
.option('-f,--force', 'Skip safety confirmation', false)
.action(async (databaseName, options) => {
const username = databaseName;
const userPwd = `${databaseName}-pwd`;
const confirmation = await confirm({
message: `This action will delete your database "${databaseName}" and cannot be reverted. Are you sure?`,
default: false,
});
const confirmation =
options.force === true ||
(await confirm({
message: `This action will delete your database "${databaseName}" and cannot be reverted. Are you sure?`,
default: false,
}));
if (confirmation !== true) {
console.info('Aborting...');
@@ -200,11 +203,14 @@ program
.command('import')
.description('Runs all queries from the given SQL file')
.argument('<sql_file_path>', 'The SQL file to import')
.action(async (sqlFilePath) => {
const confirmation = await confirm({
message: 'This action will execute any SQL statement found in the given file and cannot be reverted. Are you sure?',
default: false,
});
.option('-f,--force', 'Skip safety confirmation', false)
.action(async (sqlFilePath, options) => {
const confirmation =
options.force === true ||
(await confirm({
message: 'This action will execute any SQL statement found in the given file and cannot be reverted. Are you sure?',
default: false,
}));
if (confirmation !== true) {
console.info('Aborting...');