Coverage for sources/agentsmgr/maintenance/cli.py: 0%

18 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-24 01:49 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Maintainer-facing command-line interface with validate command. ''' 

22 

23 

24from . import __ 

25from .validation import ValidateCommand as _ValidateCommand 

26 

27 

28class MaintainerApplication( __.appcore_cli.Application ): 

29 ''' Maintainer-facing agents configuration management CLI. ''' 

30 

31 display: __.core.DisplayOptions = __.dcls.field( 

32 default_factory = __.core.DisplayOptions ) 

33 command: __.typx.Annotated[ 

34 _ValidateCommand, 

35 __.tyro.conf.subcommand( 'validate', prefix_name = False ), 

36 ] = __.dcls.field( default_factory = _ValidateCommand ) 

37 

38 async def execute( self, auxdata: __.Globals ) -> None: # pyright: ignore[reportIncompatibleMethodOverride] 

39 await self.command( auxdata ) 

40 

41 async def prepare( 

42 self, exits: __.ctxl.AsyncExitStack 

43 ) -> __.Globals: 

44 auxdata_base = await super( ).prepare( exits ) 

45 nomargs = { 

46 field.name: getattr( auxdata_base, field.name ) 

47 for field in __.dcls.fields( auxdata_base ) 

48 if not field.name.startswith( '_' ) } 

49 return __.Globals( display = self.display, **nomargs ) 

50 

51 

52def execute( ) -> None: 

53 ''' Entrypoint for maintainer-facing CLI execution. ''' 

54 config = ( __.tyro.conf.HelptextFromCommentsOff, ) 

55 try: 

56 __.asyncio.run( 

57 __.tyro.cli( MaintainerApplication, config = config )( ) ) 

58 except SystemExit: raise 

59 except BaseException: 

60 # TODO: Log exception. 

61 raise SystemExit( 1 ) from None