// Load a project so you can work on it.

import { projects } from "@/project"
import { sessionGet, sessionSet } from "@/session"
import ls from "./ls"

export default function (project: string) {
    const state = sessionGet()
    if (!project) throw `usage: load <project name>`

    if (state && projects().includes(project)) {
        sessionSet("project", project)
        sessionSet("cwd", "")
        return ls()
    } else {
        return { error: `failed to load ${project}` }
    }
}