UNPKG

sourcecontrol

Version:

A modern TypeScript CLI application for source control

54 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.statusCommand = void 0; const commander_1 = require("commander"); const index_1 = require("../../core/index"); const branch_1 = require("../../core/branch"); const refs_1 = require("../../core/refs"); const helpers_1 = require("../../utils/helpers"); const utils_1 = require("../../utils"); const status_display_1 = require("./status.display"); exports.statusCommand = new commander_1.Command('status') .description('📈 Show the working tree status') .option('-s, --short', 'Give output in short format') .option('-b, --branch', 'Show branch information') .option('-v, --verbose', 'Be verbose') .option('--ignored', 'Show ignored files') .option('--untracked-files <mode>', 'Show untracked files (no, normal, all)', 'normal') .action(async (options) => { try { const repository = await (0, helpers_1.getRepo)(); const indexManager = new index_1.IndexManager(repository); const branchManager = new branch_1.BranchManager(repository); const refManager = new refs_1.RefManager(repository); await indexManager.initialize(); await branchManager.init(); let currentBranch = null; let isDetached = false; try { currentBranch = await branchManager.getCurrentBranch(); } catch (error) { try { const headSha = await refManager.resolveReferenceToSha('HEAD'); isDetached = true; currentBranch = headSha.substring(0, 7); } catch { currentBranch = 'No commits yet'; } } const status = await indexManager.status(); if (options.short) { (0, status_display_1.displayShortStatus)(status, currentBranch, isDetached); } else { (0, status_display_1.displayLongStatus)(status, currentBranch, isDetached, options); } } catch (error) { utils_1.logger.error('Failed to get status:', error); process.exit(1); } }); //# sourceMappingURL=status.js.map