Support diaries (kinda)

This commit is contained in:
2022-03-15 17:21:10 +01:00
parent 1cad1235f2
commit 86490a3a44
7 changed files with 51 additions and 23 deletions

View File

@ -146,7 +146,9 @@ const project: Command = {
execute: (flags, args, _raw, cmdIf) => {
if (project.flags && checkFlagInclude(flags, project.flags.list)) {
const result = ["Found the following projects:"];
cmdIf.projects.forEach(project => result.push(`\t${project.name}\t${project.short}`));
cmdIf.projects.projects.forEach(project => result.push(`\t${project.name}\t${project.short_desc}`));
result.push("And the following diaries:");
cmdIf.projects.diaries.forEach(diary => result.push(`\t${diary.name}\t${diary.short_desc}`));
return result;
}
@ -154,7 +156,8 @@ const project: Command = {
if (args[0] === "this") args[0] = "homepage";
const pjt = cmdIf.projects.find(p => p.name === args[0]);
let [pjt, ptype] = [cmdIf.projects.projects.find(p => p.name === args[0]), "project"];
if (!pjt) [pjt, ptype] = [cmdIf.projects.diaries.find(p => p.name === args[0]), "diary"];
if (!pjt) return [
`Cannot find project ${args[0]}!`,
"You can see available projects using 'project -l'."
@ -170,7 +173,8 @@ const project: Command = {
}
if (project.flags && checkFlagInclude(flags, project.flags.minimal)) return pjt.desc;
cmdIf.callbacks.setModalProject(args[0]);
cmdIf.callbacks.setModalProjectType(ptype);
cmdIf.callbacks.setModalProject(pjt);
cmdIf.callbacks.setModalVisible(true);
return [];
}

View File

@ -1,16 +1,17 @@
import { Project } from "../projects/types";
import type { ProjectList } from "../projects/types";
import { printSyntax, commandList } from "./definitions";
interface CommandInterfaceCallbacks {
setModalVisible: CallableFunction,
setModalProject: CallableFunction
setModalVisible: CallableFunction;
setModalProject: CallableFunction;
setModalProjectType: CallableFunction;
}
export class CommandInterface {
callbacks: CommandInterfaceCallbacks;
projects: Project[];
projects: ProjectList;
constructor(callbacks: CommandInterfaceCallbacks, projects: Project[]) {
constructor(callbacks: CommandInterfaceCallbacks, projects: ProjectList) {
this.callbacks = callbacks;
this.projects = projects;
}

View File

@ -1,7 +1,24 @@
export interface ProjectList {
projects: Project[];
diaries: Diary[];
}
export interface Project {
name: string;
desc: string[];
short: string;
short_desc: string;
more?: string;
repo?: string;
}
export interface Diary {
name: string;
desc: string[];
short_desc: string;
more?: string;
repo?: string;
entries: {
title: string;
path: string;
}[];
}