diff options
author | Florrie <towerofnix@gmail.com> | 2018-03-19 22:55:17 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-03-19 22:55:17 -0300 |
commit | bf69e4afd6515954128f5d9129396c56553005e3 (patch) | |
tree | 7c9cfd5439236c940614db93820cd6013b29aa1d | |
parent | d1bb445c44f83602bcb8c5255788f3bc8b5cb8a5 (diff) |
Make duration graph use common CLI stuff
-rw-r--r-- | src/duration-graph.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/duration-graph.js b/src/duration-graph.js index 5d0bf85..c8fce75 100644 --- a/src/duration-graph.js +++ b/src/duration-graph.js @@ -11,6 +11,8 @@ const { flattenGrouplike } = require('./playlist-utils') +const { makePlaylistOptions } = require('./general-util') + const readFile = util.promisify(fs.readFile) const metrics = {} @@ -217,7 +219,9 @@ async function main(args) { let onlyFirst = 20 let metric = metrics.duration - await processArgv(args.slice(1), { + const { optionFunctions, getStuff } = makePlaylistOptions() + + Object.assign(optionFunctions, { '-metric': util => { const arg = util.nextArg() if (Object.keys(metrics).includes(arg)) { @@ -253,19 +257,18 @@ async function main(args) { } }, - '-only': util => util.alias('-only-first'), - 'o': util => util.alias('-only-first'), '-first': util => util.alias('-only-first'), - 'f': util => util.alias('-only-first'), '-all': util => { onlyFirst = Infinity - }, - - 'a': util => util.alias('-all') + } }) - const playlist = updatePlaylistFormat(JSON.parse(await readFile(args[0]))) + await processArgv(args, optionFunctions) + + const playlist = getStuff.activePlaylist + + console.log(playlist) for (const line of makePlaylistGraph(playlist, { graphWidth, onlyFirst, metric |