@shutootaki/gwm
Version:
git worktree manager CLI
37 lines • 1.81 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect, useState } from 'react';
import { Text, Box } from 'ink';
import { getWorktreesWithStatus, formatErrorForDisplay, } from '../utils/index.js';
import { WorktreeTable } from './WorktreeTable.js';
export const WorktreeList = () => {
const [worktrees, setWorktrees] = useState([]);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const loadWorktrees = async () => {
try {
setLoading(true);
const worktrees = await getWorktreesWithStatus();
setWorktrees(worktrees);
}
catch (err) {
setError(formatErrorForDisplay(err));
}
finally {
setLoading(false);
}
};
loadWorktrees();
}, []);
if (loading) {
return (_jsx(Box, { children: _jsx(Text, { color: "cyan", children: "Loading worktrees..." }) }));
}
if (error) {
return (_jsx(Box, { flexDirection: "column", children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) }));
}
if (worktrees.length === 0) {
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "yellow", children: "No worktrees found" }), _jsxs(Text, { color: "gray", children: ["Use ", _jsx(Text, { color: "cyan", children: "gwm add" }), " to create one"] })] }));
}
return (_jsx(WorktreeTable, { worktrees: worktrees, footer: _jsxs(Text, { color: "gray", children: ["Use ", _jsx(Text, { color: "cyan", children: "gwm go [query]" }), " to navigate,", ' ', _jsx(Text, { color: "cyan", children: "gwm remove" }), " to delete"] }) }));
};
//# sourceMappingURL=WorktreeList.js.map