You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.9 KiB
91 lines
3.9 KiB
import {Separator} from "inquirer";
|
|
import {inquire} from "../prompts/Inquire";
|
|
import {summaryPrompt} from "../prompts/implementations/SummaryPrompt";
|
|
import {journalEntryPrompt} from "../prompts/implementations/JournalEntryPrompt";
|
|
import {guidedEmpathyListPrompt} from "../prompts/implementations/GuidedEmpathyListPrompt";
|
|
import {entryMainMenuPrompt} from "../prompts/implementations/EntryMainMenuPrompt";
|
|
import {CommandModule} from "yargs";
|
|
import { registerPrompts } from "../prompts/types";
|
|
import {LocalRepository} from "../repository/LocalRepository";
|
|
import {conditionPrompt} from "../prompts/implementations/ConditionPrompt";
|
|
import {entryPrompt} from "../prompts/implementations/EntryPrompt";
|
|
import {guidedEmpathyPrompt} from "../prompts/implementations/GuidedEmpathyPrompt";
|
|
import {suicidalityPrompt} from "../prompts/implementations/SuicidalityPrompt";
|
|
|
|
export function addEntryCommand(): CommandModule {
|
|
return {
|
|
command: ["add-entry", "*"],
|
|
describe: "Adds a new entry to the journal.",
|
|
handler: async () => {
|
|
registerPrompts()
|
|
const storage = new LocalRepository()
|
|
const empathyGuide = await storage.loadEmpathyGuide()
|
|
|
|
const condition = conditionPrompt({inquire})
|
|
const summary = summaryPrompt({inquire})
|
|
const journal = journalEntryPrompt({inquire})
|
|
const suicidality = suicidalityPrompt({inquire})
|
|
const empathy = guidedEmpathyPrompt({
|
|
inquire,
|
|
guideFactory: () => empathyGuide,
|
|
show: async (value) => console.log(value),
|
|
})
|
|
const empathyList = guidedEmpathyListPrompt({inquire, promptForEmpathy: empathy})
|
|
|
|
const mainMenuItems = [
|
|
condition.mainMenu,
|
|
summary.mainMenu,
|
|
new Separator(),
|
|
journal.mainMenu,
|
|
empathyList.mainMenu,
|
|
/*
|
|
{
|
|
name: typeof entry.needs === "object" ? "Check back in on needs" : "Check in on needs",
|
|
value: NEEDS,
|
|
key: "n"
|
|
},
|
|
{
|
|
name: typeof entry.personas === "object" ? "Check back in on personas" : "Check in on personas",
|
|
value: PERSONA,
|
|
key: "p"
|
|
},
|
|
{name: typeof entry.rpg === "object" ? "Change RPG stats" : "Add RPG stats", value: RPG, key: "r"},
|
|
{
|
|
name: typeof entry.activities === "object" ? "Change record of recent activities" : "Add record of recent activities",
|
|
value: ACTIVITIES,
|
|
key: "a"
|
|
},
|
|
{
|
|
name: typeof entry.music === "object" ? "Change record of recently played music" : "Add record of recently played music",
|
|
value: MUSIC,
|
|
key: "m"
|
|
},
|
|
*/
|
|
suicidality.mainMenu,
|
|
/*
|
|
{
|
|
name: typeof entry.recoveries === "object" ? "Try more recovery methods" : "Try some recovery methods",
|
|
value: RECOVERIES,
|
|
key: "y"
|
|
},
|
|
*/
|
|
]
|
|
|
|
const mainMenu = entryMainMenuPrompt({
|
|
inquire,
|
|
choices: mainMenuItems,
|
|
showError: async (value) => console.log(value),
|
|
})
|
|
|
|
const entry = entryPrompt({
|
|
promptForCondition: condition,
|
|
promptForSummary: summary,
|
|
promptForEntryMainMenu: mainMenu,
|
|
})
|
|
|
|
const writtenEntry = await entry({})
|
|
await storage.saveEntry(writtenEntry)
|
|
console.log("Entry saved! Good work!")
|
|
}
|
|
}
|
|
} |