mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Improve selectFromList
function signature to be much more reusable
This commit is contained in:
parent
79d9ebc805
commit
7846af390e
@ -23,11 +23,6 @@ import chalk from 'chalk';
|
||||
import validation = require('./validation');
|
||||
import messages = require('./messages');
|
||||
|
||||
export interface ListSelectionEntry {
|
||||
name: string;
|
||||
extra: any;
|
||||
}
|
||||
|
||||
export function authenticate(options: {}): Promise<void> {
|
||||
return form
|
||||
.run(
|
||||
@ -250,14 +245,11 @@ export function inferOrSelectDevice(preferredUuid: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function selectFromList(
|
||||
message: string,
|
||||
selections: ListSelectionEntry[],
|
||||
): Promise<ListSelectionEntry> {
|
||||
export function selectFromList<T>(message: string, choices: Array<T & { name: string }>): Promise<T> {
|
||||
return form.ask({
|
||||
message,
|
||||
type: 'list',
|
||||
choices: _.map(selections, s => ({
|
||||
choices: _.map(choices, s => ({
|
||||
name: s.name,
|
||||
value: s,
|
||||
})),
|
||||
|
Loading…
Reference in New Issue
Block a user