@@ -121,60 +121,40 @@ def start_web_server(context_lab_instance: OpenContext, host: str, port: int, wo
121121
122122def parse_args () -> argparse .Namespace :
123123 """Parse command line arguments.
124-
124+
125125 Returns:
126126 Parsed command line arguments
127127 """
128128 parser = argparse .ArgumentParser (
129129 description = "OpenContext - Context capture, processing, storage and consumption system"
130130 )
131-
131+
132132 subparsers = parser .add_subparsers (dest = "command" , help = "Available commands" )
133-
133+
134134 # Start command
135- start_parser = subparsers .add_parser ("start" , help = "Start OpenContext" )
135+ start_parser = subparsers .add_parser ("start" , help = "Start OpenContext server " )
136136 start_parser .add_argument (
137- "-c" , "-- config" ,
138- type = str ,
137+ "-- config" ,
138+ type = str ,
139139 help = "Configuration file path"
140140 )
141141 start_parser .add_argument (
142- "--workers" ,
143- type = int ,
144- default = 1 ,
145- help = "Number of worker processes (default: 1)"
142+ "--host" ,
143+ type = str ,
144+ help = "Host address (overrides config file)"
146145 )
147-
148- # Initialize command
149- init_parser = subparsers .add_parser ("init" , help = "Initialize configuration" )
150- init_parser .add_argument (
151- "-o" , "--output" ,
152- type = str ,
153- default = "./config/config.yaml" ,
154- help = "Output configuration file path"
155- )
156-
157- # Web command
158- web_parser = subparsers .add_parser ("web" , help = "Start web interface" )
159- web_parser .add_argument (
160- "--host" ,
161- type = str ,
162- default = "localhost" ,
163- help = "Host address"
164- )
165- web_parser .add_argument (
166- "--port" ,
167- type = int ,
168- default = 8080 ,
169- help = "Port number"
146+ start_parser .add_argument (
147+ "--port" ,
148+ type = int ,
149+ help = "Port number (overrides config file)"
170150 )
171- web_parser .add_argument (
151+ start_parser .add_argument (
172152 "--workers" ,
173153 type = int ,
174154 default = 1 ,
175155 help = "Number of worker processes (default: 1)"
176156 )
177-
157+
178158 return parser .parse_args ()
179159
180160
@@ -214,10 +194,10 @@ def _run_headless_mode(lab_instance: OpenContext) -> None:
214194
215195def handle_start (args : argparse .Namespace ) -> int :
216196 """Handle the start command.
217-
197+
218198 Args:
219199 args: Parsed command line arguments
220-
200+
221201 Returns:
222202 Exit code (0 for success, 1 for failure)
223203 """
@@ -231,9 +211,10 @@ def handle_start(args: argparse.Namespace) -> int:
231211
232212 web_config = lab_instance .config .get ("web" , {})
233213 if web_config .get ("enabled" , True ):
234- host = web_config .get ("host" , "localhost" )
235- port = web_config .get ("port" , 8080 )
236-
214+ # Command line arguments override config file
215+ host = args .host if args .host else web_config .get ("host" , "localhost" )
216+ port = args .port if args .port else web_config .get ("port" , 8000 )
217+
237218 try :
238219 logger .info (f"Starting web server on { host } :{ port } " )
239220 workers = getattr (args , 'workers' , 1 )
@@ -243,7 +224,7 @@ def handle_start(args: argparse.Namespace) -> int:
243224 lab_instance .shutdown ()
244225 else :
245226 _run_headless_mode (lab_instance )
246-
227+
247228 return 0
248229def _setup_logging (config_path : Optional [str ]) -> None :
249230 """Setup logging configuration.
@@ -261,21 +242,21 @@ def _setup_logging(config_path: Optional[str]) -> None:
261242
262243def main () -> int :
263244 """Main entry point.
264-
245+
265246 Returns:
266247 Exit code (0 for success, non-zero for failure)
267248 """
268249 args = parse_args ()
269-
250+
270251 # Setup logging first
271- _setup_logging (args . config )
272-
252+ _setup_logging (getattr ( args , ' config' , None ) )
253+
273254 logger .debug (f"Command line arguments: { args } " )
274-
255+
275256 if not args .command :
276- logger .error ("No command specified. Use --help for usage information ." )
257+ logger .error ("No command specified. Use 'opencontext start' or 'opencontext --help' for usage." )
277258 return 1
278-
259+
279260 if args .command == "start" :
280261 return handle_start (args )
281262 else :
0 commit comments