MCPcopy
hub / github.com/colbymchenry/codegraph / main

Function main

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

Source from the content-addressed store, hash-verified

113}
114
115function main() {
116
117const program = new Command();
118
119// Version from package.json
120const packageJson = JSON.parse(
121 fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), 'utf-8')
122);
123
124// Make the version trivial to reach. commander's `.version()` (below) wires up
125// `--version` and `-V`; intercept the spellings it can't — lowercase `-v` and
126// single-dash `-version` — before any parsing. (commander's version short flag
127// is the capital `-V`, and its parser rejects a multi-character single-dash
128// flag.) The bare `codegraph version` subcommand is registered further down so
129// the affordance also shows up in `codegraph --help`.
130const firstArg = process.argv[2];
131if (firstArg === '-v' || firstArg === '-version') {
132 console.log(packageJson.version);
133 return;
134}
135
136// =============================================================================
137// ANSI Color Helpers (avoid chalk ESM issues)
138// =============================================================================
139
140const colors = {
141 reset: '\x1b[0m',
142 bold: '\x1b[1m',
143 dim: '\x1b[2m',
144 red: '\x1b[31m',
145 green: '\x1b[32m',
146 yellow: '\x1b[33m',
147 blue: '\x1b[34m',
148 cyan: '\x1b[36m',
149 white: '\x1b[37m',
150 gray: '\x1b[90m',
151};
152
153const chalk = {
154 bold: (s: string) => `${colors.bold}${s}${colors.reset}`,
155 dim: (s: string) => `${colors.dim}${s}${colors.reset}`,
156 red: (s: string) => `${colors.red}${s}${colors.reset}`,
157 green: (s: string) => `${colors.green}${s}${colors.reset}`,
158 yellow: (s: string) => `${colors.yellow}${s}${colors.reset}`,
159 blue: (s: string) => `${colors.blue}${s}${colors.reset}`,
160 cyan: (s: string) => `${colors.cyan}${s}${colors.reset}`,
161 white: (s: string) => `${colors.white}${s}${colors.reset}`,
162 gray: (s: string) => `${colors.gray}${s}${colors.reset}`,
163};
164
165program
166 .name('codegraph')
167 .description('Code intelligence and knowledge graph for any codebase')
168 .version(packageJson.version);
169
170// Anonymous usage telemetry (see TELEMETRY.md): record the invoked subcommand
171// NAME only — never arguments or paths. Counts buffer locally; network sends
172// piggyback on commands that run long anyway (quick commands only append to

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