Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
auto select on holding space (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
vignedev committed Aug 9, 2020
1 parent e36b1c5 commit 33efa96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const
aes = require('crypto-js/aes'),
fetch = require('node-fetch'),
url = require('url'),
{ AutoComplete, MultiSelect } = require('enquirer'),
{ AutoComplete } = require('enquirer'),
{ AutoMoveMultiSelect } = require('./lib/AutoMoveMultiSelect')
ProgressBar = require('progress'),
path = require('path'),
fs = require('fs'),
Expand All @@ -13,7 +14,7 @@ const
help: 'h', silent: 's', english: 'E',
force: 'f', list: 'l'
}})

const
baseUrl = 'https://twist.moe',
cdnUrl = 'https://twistcdn.bunny.sh',
Expand Down Expand Up @@ -66,7 +67,7 @@ Options:

if (!source && !interactive) throw new Error('Episode not available or series wasn\'t found.')

const pickedEpisodes = argv.episode ? (typeof(argv.episode) === 'string' && argv.episode != 'latest' ? getArrayOfEpisodes(sources, argv.episode) : [source]) : (await (new MultiSelect({ // Choices are broken, they don't read the value field, workaround present
const pickedEpisodes = argv.episode ? (typeof(argv.episode) === 'string' && argv.episode != 'latest' ? getArrayOfEpisodes(sources, argv.episode) : [source]) : (await (new AutoMoveMultiSelect({ // Choices are broken, they don't read the value field, workaround present
name: 'episodes', message: `Select episodes: (${getTitle(selectedAnime)})`, /*limit: 24,*/
choices: Object.keys(sources)
})).run()).map(x => sources[x])
Expand Down
12 changes: 12 additions & 0 deletions lib/AutoMoveMultiSelect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { MultiSelect } = require('enquirer')

class AutoMoveMultiSelect extends MultiSelect{
constructor(...options){
super(...options)
}
space(){
super.space()
if(this.index != this.choices.length-1) super.down()
}
}
module.exports = { AutoMoveMultiSelect }

0 comments on commit 33efa96

Please sign in to comment.