mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-03-22 03:55:19 +00:00
Implement app rm command
This commit is contained in:
parent
1c1e8b375e
commit
37c68118db
@ -2,6 +2,7 @@ _ = require('lodash')
|
||||
device = require('../device/device')
|
||||
table = require('../table/table')
|
||||
server = require('../server/server')
|
||||
widgets = require('../widgets/widgets')
|
||||
applicationModel = require('../models/application')
|
||||
authHooks = require('../hooks/auth')
|
||||
config = require('../config')
|
||||
@ -38,3 +39,9 @@ exports.restart = authHooks.failIfNotLoggedIn (id) ->
|
||||
# TODO: Move this URL to config
|
||||
server.post "/application/#{id}/restart", (error) ->
|
||||
throw error if error?
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id) ->
|
||||
widgets.confirmRemoval 'application', (error, confirmed) ->
|
||||
return if not confirmed
|
||||
applicationModel.remove(id).catch (error) ->
|
||||
throw error if error?
|
||||
|
@ -41,6 +41,11 @@ program
|
||||
.description('Restart an application')
|
||||
.action(app.restart)
|
||||
|
||||
program
|
||||
.command('app:rm <id>')
|
||||
.description('Remove an application')
|
||||
.action(app.remove)
|
||||
|
||||
# ---------- Device Module ----------
|
||||
device = require('./actions/device')
|
||||
|
||||
|
@ -18,3 +18,8 @@ exports.get = (id) ->
|
||||
Promise.reject(new Error('Not found'))
|
||||
|
||||
return application
|
||||
|
||||
exports.remove = (id) ->
|
||||
return canvas.delete
|
||||
resource: 'application'
|
||||
id: id
|
||||
|
@ -14,3 +14,14 @@ exports.login = (callback) ->
|
||||
message: 'Password'
|
||||
}
|
||||
], _.partial(callback, null))
|
||||
|
||||
exports.confirmRemoval = (name, callback) ->
|
||||
inquirer.prompt [
|
||||
{
|
||||
type: 'confirm'
|
||||
name: 'confirmed'
|
||||
message: "Are you sure you want to delete the #{name}?"
|
||||
default: false
|
||||
}
|
||||
], (response) ->
|
||||
return callback(null, response.confirmed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user