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