Skip to content

Commit b4ff97d

Browse files
author
Evan Prodromou
committed
Only delete if flag is set or prompt is given
1 parent 5091474 commit b4ff97d

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

fuzzy.ai-cmdln.coffee

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
path = require 'path'
2020
fs = require 'fs'
21+
readline = require 'readline'
2122

2223
FuzzyAIClient = require 'fuzzy.ai'
2324
yargs = require 'yargs'
@@ -54,6 +55,9 @@ argv = yargs
5455
.describe('b', "Batch size")
5556
.number('b')
5657
.default('b', 128)
58+
.boolean('y')
59+
.alias('y', 'yes')
60+
.describe('y', 'Answer "yes" to all questions')
5761
.env('FUZZY_AI')
5862
.alias('c', 'config')
5963
.describe('c', 'Config file')
@@ -213,12 +217,26 @@ handler =
213217
], callback
214218
], callback
215219
delete: (client, argv, callback) ->
216-
async.waterfall [
217-
(callback) ->
218-
toID client, argv.agent, callback
219-
(id, callback) ->
220-
client.deleteAgent id, callback
221-
], callback
220+
doDelete = (callback) ->
221+
async.waterfall [
222+
(callback) ->
223+
toID client, argv.agent, callback
224+
(id, callback) ->
225+
client.deleteAgent id, callback
226+
], callback
227+
228+
if argv.y
229+
doDelete callback
230+
else
231+
rl = readline.createInterface
232+
input: process.stdin
233+
output: process.stdout
234+
rl.question "Really delete agent #{argv.agent}? ", (answer) ->
235+
if answer == "y"
236+
doDelete callback
237+
else
238+
callback null
239+
222240
batch: (client, argv, callback) ->
223241
id = null
224242
inputNames = null

0 commit comments

Comments
 (0)