@@ -35,6 +35,8 @@ internal class ProxyHost
3535 private readonly Option < bool ? > _installCertOption ;
3636 internal static readonly string UrlsToWatchOptionName = "--urls-to-watch" ;
3737 private static Option < IEnumerable < string > ? > ? _urlsToWatchOption ;
38+ internal static readonly string TimeoutOptionName = "--timeout" ;
39+ private readonly Option < long ? > _timeoutOption ;
3840
3941 private static bool _configFileResolved = false ;
4042 private static string _configFile = "devproxyrc.json" ;
@@ -268,6 +270,26 @@ public ProxyHost()
268270 Arity = ArgumentArity . ZeroOrMore
269271 } ;
270272 _urlsToWatchOption . AddAlias ( "-u" ) ;
273+
274+ _timeoutOption = new Option < long ? > ( TimeoutOptionName , "Time in seconds after which Dev Proxy exits. Resets when Dev Proxy intercepts a request." )
275+ {
276+ ArgumentHelpName = "timeout" ,
277+ } ;
278+ _timeoutOption . AddValidator ( input =>
279+ {
280+ try
281+ {
282+ if ( ! long . TryParse ( input . Tokens [ 0 ] . Value , out long timeoutInput ) || timeoutInput < 1 )
283+ {
284+ input . ErrorMessage = $ "{ input . Tokens [ 0 ] . Value } is not valid as a timeout value";
285+ }
286+ }
287+ catch ( InvalidOperationException ex )
288+ {
289+ input . ErrorMessage = ex . Message ;
290+ }
291+ } ) ;
292+ _timeoutOption . AddAlias ( "-t" ) ;
271293
272294 ProxyCommandHandler . Configuration . ConfigFile = ConfigFile ;
273295 }
@@ -291,7 +313,8 @@ public RootCommand GetRootCommand(ILogger logger)
291313 _installCertOption ,
292314 // _urlsToWatchOption is set while initialize the Program
293315 // As such, it's always set here
294- _urlsToWatchOption !
316+ _urlsToWatchOption ! ,
317+ _timeoutOption
295318 } ;
296319 command . Description = "Dev Proxy is a command line tool for testing Microsoft Graph, SharePoint Online and any other HTTP APIs." ;
297320
@@ -457,6 +480,7 @@ public RootCommand GetRootCommand(ILogger logger)
457480 _noFirstRunOption ,
458481 _asSystemProxyOption ,
459482 _installCertOption ,
483+ _timeoutOption ,
460484 .. optionsFromPlugins ,
461485 ] ,
462486 urlsToWatch ,
0 commit comments