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

Function main

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

Source from the content-addressed store, hash-verified

134}
135
136function main() {
137
138const program = new Command();
139
140// Version from package.json
141const packageJson = JSON.parse(
142 fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')
143);
144
145// Make the version trivial to reach. commander's `.version()` (below) wires up
146// `--version` and `-V`; intercept the spellings it can't — lowercase `-v` and
147// single-dash `-version` — before any parsing. (commander's version short flag
148// is the capital `-V`, and its parser rejects a multi-character single-dash
149// flag.) The bare `codegraph version` subcommand is registered further down so
150// the affordance also shows up in `codegraph --help`.
151const firstArg = process.argv[2];
152if (firstArg === '-v' || firstArg === '-version') {
153 console.log(packageJson.version);
154 return;
155}
156
157// =============================================================================
158// ANSI Color Helpers (avoid chalk ESM issues)
159// =============================================================================
160
161// `--color` / `--no-color` are global and position-independent — they were
162// already read by ansiColorsEnabled() at module load, so strip them before
163// commander parses (a subcommand would otherwise reject the unknown flag).
164process.argv = process.argv.filter((a) => a !== '--color' && a !== '--no-color');
165
166const colors = COLORS_ENABLED
167 ? {
168 reset: '\x1b[0m',
169 bold: '\x1b[1m',
170 dim: '\x1b[2m',
171 red: '\x1b[31m',
172 green: '\x1b[32m',
173 yellow: '\x1b[33m',
174 blue: '\x1b[34m',
175 cyan: '\x1b[36m',
176 white: '\x1b[37m',
177 gray: '\x1b[90m',
178 }
179 : {
180 reset: '',
181 bold: '',
182 dim: '',
183 red: '',
184 green: '',
185 yellow: '',
186 blue: '',
187 cyan: '',
188 white: '',
189 gray: '',
190 };
191
192const chalk = {
193 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
unsafeIndexRootReasonFunction · 0.90
isInitializedFunction · 0.90
getGlyphsFunction · 0.90
createShimmerProgressFunction · 0.90
getCodeGraphDirFunction · 0.90
worktreeMismatchWarningFunction · 0.90
hasStructuralKeywordFunction · 0.90

Tested by

no test coverage detected