diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-04-17 00:05:50 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-04-17 00:05:50 -0300 |
commit | 410971a0c815a3e994b239161ed4680beac20abf (patch) | |
tree | 347e852f7f0454a302642807d1e1289483d52195 | |
parent | 385faccb5a5be64acd5ca65ace26d6a7db37b64f (diff) |
local REPL input logging / history file
-rw-r--r-- | src/repl.js | 22 | ||||
-rwxr-xr-x | src/upd8.js | 10 |
2 files changed, 22 insertions, 10 deletions
diff --git a/src/repl.js b/src/repl.js index 2e61081e..aea66e35 100644 --- a/src/repl.js +++ b/src/repl.js @@ -1,6 +1,8 @@ +import * as os from 'os'; import * as path from 'path'; import * as repl from 'repl'; import { fileURLToPath } from 'url'; +import { promisify } from 'util'; import { filterDuplicateDirectories, @@ -24,10 +26,15 @@ async function main() { 'show-traces': { type: 'flag' }, + + 'no-history': { + type: 'flag' + }, }); const dataPath = miscOptions['data-path'] || process.env.HSMUSIC_DATA; const showAggregateTraces = miscOptions['show-traces'] ?? false; + const disableHistory = miscOptions['no-history'] ?? false; if (!dataPath) { logError`Expected --data-path option or HSMUSIC_DATA to be set`; @@ -89,6 +96,21 @@ async function main() { wikiData, {wikiData, WD: wikiData} ); + + if (disableHistory) { + console.log(`\rInput history disabled (--no-history provided)`); + replServer.displayPrompt(true); + } else { + const historyFile = path.join(os.homedir(), '.hsmusic_repl_history'); + replServer.setupHistory(historyFile, err => { + if (err) { + console.error(`\rFailed to begin locally logging input history to ${historyFile} (provide --no-history to disable)`); + } else { + console.log(`\rLogging input history to ${historyFile} (provide --no-history to disable)`); + } + replServer.displayPrompt(true); + }); + } } main().catch(error => { diff --git a/src/upd8.js b/src/upd8.js index 3f583a11..5908bc2d 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -1603,16 +1603,6 @@ async function main() { // which are only available after the initial linking. sortWikiDataArrays(wikiData); - // const track = WD.trackData.find(t => t.name === 'Under the Sun'); - // console.log(track.album.trackGroups.find(tg => tg.tracks.includes(track)).color, track.color); - // console.log(WD.homepageLayout.rows[0].countAlbumsFromGroup); - // console.log(WD.albumData.map(a => `${a.name} (${a.date.toDateString()})`).join('\n')); - // console.log(WD.groupData.find(g => g.name === 'Fandom').albums.map(a => `${a.name} (${a.date.toDateString()})`).join('\n')); - // console.log(WD.trackData.find(t => t.name === 'Another Chance').commentatorArtists.map(artist => `${artist.name} - commentated ${artist.tracksAsCommentator.length} tracks, ${artist.albumsAsCommentator.length} albums`).join('\n')); - // console.log(WD.groupCategoryData.map(c => `${c.name} (${c.groups.map(g => g.name).join(', ')})`).join('\n')); - // console.log(WD.groupData.map(g => `${g.name} (${g.category?.name})`).join('\n')); - // return; - // Update languages o8ject with the wiki-specified default language! // This will make page files for that language 8e gener8ted at the root // directory, instead of the language-specific su8directory. |