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

Function main

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected