Skip to content

Commit

Permalink
Merge pull request #120 from zanerock/work-liquid-labs/cloudsite/117
Browse files Browse the repository at this point in the history
Implement interactive site destroy confirmation
  • Loading branch information
zanerock authored Mar 28, 2024
2 parents 6124a10 + ff44907 commit c59bc7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli/lib/handle-create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const handleCreate = async ({ argv, db }) => {
}
if (interrogationBundle.actions.length > 1) {
const questioner = new Questioner({ interrogationBundle, output : progressLogger })
await questioner.question()
await questioner.question();

({ apexDomain = apexDomain, sourcePath = sourcePath } = questioner.values)
}
Expand Down
20 changes: 17 additions & 3 deletions src/cli/lib/handle-destroy.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
import commandLineArgs from 'command-line-args'
import { Questioner } from 'question-and-answer'

import { cliSpec } from '../constants'
import { destroy } from '../../lib/actions/destroy'
import { errorOut } from './error-out'
import { getSiteInfo } from './get-site-info'
import { progressLogger } from '../../lib/shared/progress-logger'

const handleDestroy = async ({ argv, db }) => {
const destroyOptionsSpec = cliSpec.commands.find(({ name }) => name === 'destroy').arguments
const destroyOptions = commandLineArgs(destroyOptionsSpec, { argv })
const apexDomain = destroyOptions['apex-domain']
const { confirmed } = destroyOptions
let { confirmed } = destroyOptions

const siteInfo = getSiteInfo({ apexDomain, db })

if (confirmed !== true) {
errorOut("Interactive mode not yet implement. You must include the '--confirmed' option.\n", 3)
const interrogationBundle = {
actions : [{
prompt : `Confirm destruction of '${apexDomain}'?`,
paramType : 'boolean',
parameter : 'confirmed'
}]
}
const questioner = new Questioner({ interrogationBundle, output : progressLogger })
await questioner.question()
confirmed = questioner.getResult('confirmed').value

if (confirmed !== true) {
progressLogger.write('Not confirmed; canceling operation.\n')
return
}
}

const deleted = await destroy({ db, siteInfo, verbose : true })
Expand Down

0 comments on commit c59bc7f

Please sign in to comment.