import prompts from 'prompts' ; import type { Extras , Resolution } from '../types' ; param { number } initial returns { Promise < number > } export const downloadThreads = async ( initial ) : Promise < number > => ( await prompts ( { type : 'number' , name : 'downloadThreads' , message : 'What is the number of threads to use for downloads? (-1 for unlimited).' , initial , min : - 1 , } ) ) . downloadThreads || initial ; param { number } initial param { Array < number > } resolutions returns { Promise < number > } export const videoResolution = async ( initial , resolutions ) : Promise < Resolution > => ( await prompts ( { type : 'select' , name : 'resolution' , message : 'What resolution would you like to download in?' , choices : resolutions . map ( ( res ) => ( { title : `${ res }p` , value : res , disabled : false } ) ) , initial : resolutions . indexOf ( initial ) , } ) ) . resolution || initial ; param { string } initial param { Array < string > } options returns { Promise < string > } export const fileFormatting = async ( initial , options ) : Promise < string > => ( await prompts ( { type : 'text' , name : 'fileFormatting' , message : 'What format should be used for saving videos? The following values can be used:\n' + options . reduce ( ( str , option ) => `${ str } - ${ option }\n` , '' ) , initial , } ) ) . fileFormatting || initial ; param options returns { Promise < Array < string > > } export const extras = async ( initial ) : Promise < Array < string > | undefined > => ( await prompts ( { type : 'multiselect' , name : 'extras' , message : 'Enable/Disable Extra Options:' , choices : ( Object . keys ( initial ) as [ keyof Extras ] ) . map ( ( option ) => ( { title : option , value : option , selected : initial [ option ] } ) ) , hint : '- Space to select. Return to submit' , } ) ) . extras ; /**
 * Prompts user if they want to automatically delete videos x days.
 */ export const deleteOldVideos = async ( initial ) : Promise < boolean > => ( await prompts ( { type : 'toggle' , name : 'deleteOldVideos' , message : 'Do you want to automatically delete videos after a specified number of days?' , initial , active : 'Yes' , inactive : 'No' , } ) ) . deleteOldVideos ; /**
 * Prompts user for how many days to keep videos.
 */ export const daysToKeepVideos = async ( initial ) : Promise < number > => ( await prompts ( { type : 'number' , name : 'daysToKeepVideos' , message : 'How many days do you want to keep videos before they are deleted?' , initial , min : 1 , } ) ) . daysToKeepVideos || initial ;