Skip to content

Commit

Permalink
Implement STDOUT cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi Constantin committed Mar 9, 2020
1 parent 751f652 commit 1e530de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions bin/clean-mark
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,24 @@ function getMarker (type) {
const useTitle = argv['name-title']
const type = (argv.t || argv.type || '').toLowerCase()
const output = argv.o || argv.output
const useStdout = argv.stdout
const ext = getExtension(type)
const mark = getMarker(type)

console.log('=> Processing URL ...')
if (!useStdout) {
console.log('=> Processing URL ...')
}

// Cycle all provided URLs
for (const link of argv._) {
try {
dict = await c(link, {useDatabase: useDb, fileType: type})
dict = await c(link, { useDatabase: useDb, fileType: type })
const stat = `paragraph=${s.paragraphCount(dict.text)} sentences=${s.sentenceCount(dict.text)}, words=${s.wordCount(dict.text)}`
const text = `${mark[0]}\nlink: ${dict.url}\ntitle: ${dict.title}\ndescription: ${dict.description}\nkeywords: ${dict.keywords}\nauthor: ${dict.author}\ndate: ${dict.date}\npublisher: ${dict.publisher}\nstats: ${stat}\n${mark[1]}\n${dict.text}`
if (useStdout) {
console.log(text.trim())
return
}
let path
if (useTitle) {
path = dict.title.replace(/[ \t-]+/g, '-') + ext
Expand All @@ -69,5 +76,7 @@ function getMarker (type) {
}
}

console.log('=> URL converted!')
if (!useStdout) {
console.log('=> URL converted!')
}
})()
3 changes: 2 additions & 1 deletion bin/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Options

-o, --output Specify output file name
(auto-generated by default)
-t, --type Specify output file type
--stdout Write to STDOUT instead of a file
-t, --type Specify output format type
(HTML, TEXT, or Markdown by default)
--name-title Use the title as output name
--nodb Don't use the A-Extractor database
Expand Down

0 comments on commit 1e530de

Please sign in to comment.