MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / main

Function main

src/bin/codegraph.ts:161–3506  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159}
160
161function main() {
162
163const program = new Command();
164
165// Version from package.json
166const packageJson = JSON.parse(
167 fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')
168);
169
170// Make the version trivial to reach. commander's `.version()` (below) wires up
171// `--version` and `-V`; intercept the spellings it can't — lowercase `-v` and
172// single-dash `-version` — before any parsing. (commander's version short flag
173// is the capital `-V`, and its parser rejects a multi-character single-dash
174// flag.) The bare `codegraph version` subcommand is registered further down so
175// the affordance also shows up in `codegraph --help`.
176const firstArg = process.argv[2];
177if (firstArg === '-v' || firstArg === '-version') {
178 console.log(packageJson.version);
179 return;
180}
181
182// =============================================================================
183// ANSI Color Helpers (avoid chalk ESM issues)
184// =============================================================================
185
186// `--color` / `--no-color` are global and position-independent — they were
187// already read by ansiColorsEnabled() at module load, so strip them before
188// commander parses (a subcommand would otherwise reject the unknown flag).
189process.argv = process.argv.filter((a) => a !== '--color' && a !== '--no-color');
190
191const colors = COLORS_ENABLED
192 ? {
193 reset: '\x1b[0m',
194 bold: '\x1b[1m',
195 dim: '\x1b[2m',
196 red: '\x1b[31m',
197 green: '\x1b[32m',
198 yellow: '\x1b[33m',
199 blue: '\x1b[34m',
200 cyan: '\x1b[36m',
201 white: '\x1b[37m',
202 gray: '\x1b[90m',
203 }
204 : {
205 reset: '',
206 bold: '',
207 dim: '',
208 red: '',
209 green: '',
210 yellow: '',
211 blue: '',
212 cyan: '',
213 white: '',
214 gray: '',
215 };
216
217const chalk = {
218 bold: (s: string) => `${colors.bold}${s}${colors.reset}`,

Callers 1

codegraph.tsFile · 0.70

Calls 15

executeMethod · 0.95
startMethod · 0.95
getTelemetryFunction · 0.90
isInitializedFunction · 0.90
getGlyphsFunction · 0.90
unsafeIndexRootReasonFunction · 0.90
createShimmerProgressFunction · 0.90
getCodeGraphDirFunction · 0.90
worktreeMismatchWarningFunction · 0.90
stripSystemRemindersFunction · 0.90

Tested by

no test coverage detected