refactor: prompt params
This commit is contained in:
parent
1680a35369
commit
0d8ab40ba9
1 changed files with 13 additions and 5 deletions
18
src/cli.ts
18
src/cli.ts
|
@ -15,9 +15,17 @@ const chalk: typeof import('chalk') = require('chalk')
|
||||||
|
|
||||||
const SCORE_URL_PREFIX = 'https://musescore.com/'
|
const SCORE_URL_PREFIX = 'https://musescore.com/'
|
||||||
|
|
||||||
|
interface Params {
|
||||||
|
url: string;
|
||||||
|
confirmed: boolean;
|
||||||
|
part: number;
|
||||||
|
types: number[];
|
||||||
|
dest: string;
|
||||||
|
}
|
||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
// ask for the page url
|
// ask for the page url
|
||||||
const { url } = await inquirer.prompt({
|
const { url } = await inquirer.prompt<Params>({
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'url',
|
name: 'url',
|
||||||
message: 'Score URL:',
|
message: 'Score URL:',
|
||||||
|
@ -33,7 +41,7 @@ void (async () => {
|
||||||
const fileName = scoreinfo.fileName
|
const fileName = scoreinfo.fileName
|
||||||
|
|
||||||
// confirmation
|
// confirmation
|
||||||
const { confirmed } = await inquirer.prompt({
|
const { confirmed } = await inquirer.prompt<Params>({
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'confirmed',
|
name: 'confirmed',
|
||||||
message: 'Continue?',
|
message: 'Continue?',
|
||||||
|
@ -81,7 +89,7 @@ void (async () => {
|
||||||
const typeChoices = INDV_DOWNLOADS.map((d, i) => ({ name: d.name, value: i }))
|
const typeChoices = INDV_DOWNLOADS.map((d, i) => ({ name: d.name, value: i }))
|
||||||
|
|
||||||
// part selection
|
// part selection
|
||||||
const { part }: { part: number } = await inquirer.prompt({
|
const { part } = await inquirer.prompt<Params>({
|
||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'part',
|
name: 'part',
|
||||||
message: 'Part Selection',
|
message: 'Part Selection',
|
||||||
|
@ -91,7 +99,7 @@ void (async () => {
|
||||||
await score.setExcerptId(part)
|
await score.setExcerptId(part)
|
||||||
|
|
||||||
// filetype selection
|
// filetype selection
|
||||||
const { types }: { types: number[] } = await inquirer.prompt({
|
const { types } = await inquirer.prompt<Params>({
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
name: 'types',
|
name: 'types',
|
||||||
message: 'Filetype Selection',
|
message: 'Filetype Selection',
|
||||||
|
@ -100,7 +108,7 @@ void (async () => {
|
||||||
const filetypes = types.map(i => INDV_DOWNLOADS[i])
|
const filetypes = types.map(i => INDV_DOWNLOADS[i])
|
||||||
|
|
||||||
// destination directory
|
// destination directory
|
||||||
const { dest } = await inquirer.prompt({
|
const { dest } = await inquirer.prompt<Params>({
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'dest',
|
name: 'dest',
|
||||||
message: 'Destination Directory:',
|
message: 'Destination Directory:',
|
||||||
|
|
Loading…
Reference in a new issue