Skip to content

Commit 3d064e8

Browse files
committed
Added cmd launcher
1 parent b274cbd commit 3d064e8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { importNotes } from './src/notes_importer.js'
2+
3+
await main()
4+
5+
async function main() {
6+
const args = process.argv.slice(2)
7+
const command = args[0]
8+
9+
switch (command) {
10+
case '--help':
11+
printHelp()
12+
return
13+
case '--import':
14+
await importNotes(args[1])
15+
return
16+
default:
17+
printHelp()
18+
}
19+
}
20+
21+
function printHelp() {
22+
console.info("--help - Print help")
23+
console.info("--import \"/data/notes\" - Import markdown notes from directory")
24+
console.info("--status - Show count of imported notes")
25+
console.info("--clean-db - Clean local cache db with imported notes")
26+
}

src/notes_importer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { addBlocks, createPage } from './notion_api.js'
44
import { addImportStatus, loadImportStatuses } from './db.js'
55

66

7-
const notesDir = '/home/phpusr/tmp/notes/NOTES/car'
87
const importedNotes = {}
9-
await importNotes()
108

11-
async function importNotes() {
9+
export async function importNotes(notesDir) {
1210
const importedNoteList = await loadImportStatuses()
1311
importedNoteList.forEach(noteInfo => importedNotes[noteInfo.filePath] = noteInfo)
1412
console.info(`\nLoaded already imported ${importedNoteList.length} notes`)

0 commit comments

Comments
 (0)