From 60d842bac79a05a8848ce1e63eedc4e31a1e0bda Mon Sep 17 00:00:00 2001 From: Xmader Date: Sat, 2 Jan 2021 02:34:19 -0500 Subject: [PATCH] feat: add View in LibreScore in msdl cli --- src/cli.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 5d88b0f..4dd5d78 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -8,6 +8,7 @@ import os from 'os' import { fetchMscz, setMscz, MSCZ_URL_SYM } from './mscz' import { loadMscore, INDV_DOWNLOADS, WebMscore } from './mscore' import { ScoreInfo, ScoreInfoHtml, ScoreInfoObj, getActualId } from './scoreinfo' +import { getLibreScoreLink } from './librescore-link' import { escapeFilename } from './utils' import i18n from './i18n' @@ -38,6 +39,7 @@ void (async () => { } // For MacOS, no hint is needed because the paste shortcut is universal. let scoreinfo: ScoreInfo + let librescoreLink: Promise | undefined // ask for the page url or path to local file const { fileInit } = await inquirer.prompt({ type: 'input', @@ -77,7 +79,12 @@ void (async () => { default: true, }) if (!confirmed) return - console.log() // print a blank line to the terminal + + // initiate LibreScore link request + librescoreLink = getLibreScoreLink(scoreinfo) + + // print a blank line to the terminal + console.log() } else { scoreinfo = new ScoreInfoObj(0, path.basename(fileInit, EXT)) } @@ -105,6 +112,11 @@ void (async () => { if (!isLocalFile) { spinner.info(`File URL: ${scoreinfo.store.get(MSCZ_URL_SYM) as string}`) } + if (librescoreLink) { + try { + spinner.info(`View in LibreScore: ${await librescoreLink}`) + } catch { } // it doesn't affect the main feature + } spinner.start() // load score using webmscore