Show device types when selecting applications

Some CLI commans prompt to select an existing application, presending a
dropdown with all the application names, however it's hard to remember
which application belon to which device type, which makes it easier to
select the wrong application.
This commit is contained in:
Juan Cruz Viotti 2015-11-23 09:23:08 -04:00
parent 65646d1206
commit e08c3752f9
2 changed files with 23 additions and 4 deletions

View File

@ -52,7 +52,12 @@
return form.ask({
message: 'Select an application',
type: 'list',
choices: _.pluck(applications, 'app_name')
choices: _.map(applications, function(application) {
return {
name: application.app_name + " (" + application.device_type + ")",
value: application.app_name
};
})
});
});
};
@ -63,7 +68,12 @@
return;
}
return resin.models.application.getAll().then(function(applications) {
applications = _.pluck(applications, 'app_name');
applications = _.map(applications, function(application) {
return {
name: application.app_name + " (" + application.device_type + ")",
value: application.app_name
};
});
applications.unshift({
name: 'Create a new application',
value: null

View File

@ -35,13 +35,22 @@ exports.selectApplication = (filter) ->
return form.ask
message: 'Select an application'
type: 'list'
choices: _.pluck(applications, 'app_name')
choices: _.map applications, (application) ->
return {
name: "#{application.app_name} (#{application.device_type})"
value: application.app_name
}
exports.selectOrCreateApplication = ->
resin.models.application.hasAny().then (hasAnyApplications) ->
return if not hasAnyApplications
resin.models.application.getAll().then (applications) ->
applications = _.pluck(applications, 'app_name')
applications = _.map applications, (application) ->
return {
name: "#{application.app_name} (#{application.device_type})"
value: application.app_name
}
applications.unshift
name: 'Create a new application'
value: null