44 * gh-attach CLI entry point.
55 */
66
7+ import { readFileSync } from "fs" ;
78import { Command } from "commander" ;
89
10+ const pkg = JSON . parse ( readFileSync ( new URL ( "../../package.json" , import . meta. url ) , "utf8" ) ) ;
11+
912const program = new Command ( ) ;
1013
1114program
1215 . name ( "gh-attach" )
1316 . description ( "Upload images to GitHub issues, PRs, and comments" )
14- . version ( "0.0.0-development" ) ;
17+ . version ( pkg . version ) ;
1518
1619program
1720 . command ( "upload" )
@@ -22,21 +25,37 @@ program
2225 . option ( "--format <type>" , "Output format: markdown, url, json" , "markdown" )
2326 . option ( "--stdin" , "Read image from stdin" )
2427 . option ( "--filename <name>" , "Filename when using --stdin" )
25- . action ( async ( _files , _options ) => {
26- // TODO: Implement upload command
27- console . error ( "Upload command not yet implemented" ) ;
28- process . exit ( 1 ) ;
28+ . action ( async ( files , options ) => {
29+ try {
30+ const { uploadCommand } = await import ( "./commands/upload.js" ) ;
31+ await uploadCommand ( files , options ) ;
32+ } catch ( err ) {
33+ if ( err instanceof Error ) {
34+ console . error ( `Error: ${ err . message } ` ) ;
35+ } else {
36+ console . error ( `Error: ${ String ( err ) } ` ) ;
37+ }
38+ process . exit ( 1 ) ;
39+ }
2940 } ) ;
3041
3142program
3243 . command ( "login" )
3344 . description ( "Authenticate with GitHub via browser" )
3445 . option ( "--state-path <path>" , "Path to save session state" )
3546 . option ( "--status" , "Check current authentication status" )
36- . action ( async ( _options ) => {
37- // TODO: Implement login command
38- console . error ( "Login command not yet implemented" ) ;
39- process . exit ( 1 ) ;
47+ . action ( async ( options ) => {
48+ try {
49+ const { loginCommand } = await import ( "./commands/login.js" ) ;
50+ await loginCommand ( options ) ;
51+ } catch ( err ) {
52+ if ( err instanceof Error ) {
53+ console . error ( `Error: ${ err . message } ` ) ;
54+ } else {
55+ console . error ( `Error: ${ String ( err ) } ` ) ;
56+ }
57+ process . exit ( 1 ) ;
58+ }
4059 } ) ;
4160
4261program
@@ -45,21 +64,38 @@ program
4564 . argument ( "<action>" , "Action: list, set, get" )
4665 . argument ( "[key]" , "Configuration key" )
4766 . argument ( "[value]" , "Configuration value" )
48- . action ( async ( _action , _key , _value ) => {
49- // TODO: Implement config command
50- console . error ( "Config command not yet implemented" ) ;
51- process . exit ( 1 ) ;
67+ . action ( async ( action , key , value ) => {
68+ try {
69+ const { configCommand } = await import ( "./commands/config.js" ) ;
70+ await configCommand ( action , key , value ) ;
71+ } catch ( err ) {
72+ if ( err instanceof Error ) {
73+ console . error ( `Error: ${ err . message } ` ) ;
74+ } else {
75+ console . error ( `Error: ${ String ( err ) } ` ) ;
76+ }
77+ process . exit ( 1 ) ;
78+ }
5279 } ) ;
5380
5481program
5582 . command ( "mcp" )
5683 . description ( "Start the MCP server" )
5784 . option ( "--transport <type>" , "Transport: stdio, http" , "stdio" )
5885 . option ( "--port <number>" , "Port for HTTP transport" , "3000" )
59- . action ( async ( _options ) => {
60- // TODO: Implement MCP server command
61- console . error ( "MCP server not yet implemented" ) ;
62- process . exit ( 1 ) ;
86+ . action ( async ( options ) => {
87+ try {
88+ const { mcpCommand } = await import ( "./commands/mcp.js" ) ;
89+ await mcpCommand ( options ) ;
90+ } catch ( err ) {
91+ if ( err instanceof Error ) {
92+ console . error ( `Error: ${ err . message } ` ) ;
93+ } else {
94+ console . error ( `Error: ${ String ( err ) } ` ) ;
95+ }
96+ process . exit ( 1 ) ;
97+ }
6398 } ) ;
6499
65100program . parse ( ) ;
101+
0 commit comments