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

Function main

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

Source from the content-addressed store, hash-verified

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