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

Function main

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

Source from the content-addressed store, hash-verified

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