Adding "--force" flag to some commands (#1)
* Adding "--force" flag to "drop" command * Adding "--force" flag to "import" command
This commit is contained in:
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name: Lint
|
||||
on: [push, pull_request]
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
|
||||
26
src/index.ts
26
src/index.ts
@@ -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...');
|
||||
|
||||
Reference in New Issue
Block a user