Commit 25e48b6c authored by Steve Streza's avatar Steve Streza
Browse files

Cleanup

parent ccf132f7
import * as Commander from "commander"
export default interface Command {
(commander: Commander.CommanderStatic): void;
}
\ No newline at end of file
import Command from "../command"
import createStore from "../../util/createStore"
import journalName from "../../util/journalName"
export default ((Commander) => {
Commander
.command("create <message>")
.description("creates a new journal entry")
.action(message => {
const journal = journalName(Commander);
const store = createStore(Commander);
if (message && journal) {
store.accessor
.create(journal, {
date: new Date(),
data: {
message
}
})
.subscribe({
error: error => {
console.error("ERROR: ", error);
process.exit(1)
}
});
}
})
}) as Command
import Command from "../command"
import createStore from "../../util/createStore"
export default ((Commander) => {
Commander
.command("journals")
.description("lists journals")
.action(() => {
const store = createStore(Commander);
store.accessor.listJournals()
.subscribe({
next: j => {
console.log("" + j.slug)
}
})
})
}) as Command
import Command from "../command"
import createStore from "../../util/createStore"
import journalName from "../../util/journalName"
export default ((Commander) => {
Commander
.command("list")
.description("lists the contents of the journal")
.action(() => {
const store = createStore(Commander)
store.accessor.list(journalName(Commander))
.subscribe({
next: entry => {
if (entry.date) {
console.log("" + entry.date.toLocaleDateString() + " " + entry.date.toLocaleTimeString() + ": " + entry.data.message)
}
else {
console.log("" + entry.data.message)
}
}
})
})
}) as Command
import Command from "../command"
import createStore from "../../util/createStore"
import journalName from "../../util/journalName"
export default ((Commander) => {
Commander
.command("search [term]")
.description("searches the messages in the journal for a given term")
.action((term: string) => {
if (term) {
const store = createStore(Commander)
store.accessor.search(term, journalName(Commander))
.subscribe({
next: entry => {
if (entry.date) {
console.log("" + entry.date.toLocaleDateString() + " " + entry.date.toLocaleTimeString() + ": " + entry.data.message)
}
else {
console.log("" + entry.data.message)
}
}
})
}
})
}) as Command
import { CommanderStatic } from "commander"
import DataStore from "@microjournal/data-store";
import FolderAccessor from "@microjournal/accessor-folder";
import { join as joinPath } from "path"
import { homedir } from "os"
export default (Commander: CommanderStatic) => {
const path = (Commander.path as string) || joinPath(homedir(), ".microjournal")
const accessor = new FolderAccessor(path);
const store = new DataStore(accessor);
return store
}
import { CommanderStatic } from "commander"
export default (Commander: CommanderStatic) =>
(Commander.journal as string) || "personal";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment