Coverage for sources / agentsmgr / cli.py: 53%
19 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-01 15:37 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-01 15:37 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
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#============================================================================#
21''' Command-line interface. '''
24from . import __
25from . import core as _core
26from . import detection as _detection
27from . import population as _population
30class Application( __.appcore_cli.Application ):
31 ''' Agents configuration management CLI. '''
33 display: _core.DisplayOptions = __.dcls.field(
34 default_factory = _core.DisplayOptions )
35 command: __.typx.Union[
36 __.typx.Annotated[
37 _detection.DetectCommand,
38 __.tyro.conf.subcommand( 'detect', prefix_name = False ),
39 ],
40 __.typx.Annotated[
41 _population.PopulateCommand,
42 __.tyro.conf.subcommand( 'populate', prefix_name = False ),
43 ],
44 ] = __.dcls.field( default_factory = _detection.DetectCommand )
46 async def execute( self, auxdata: _core.Globals ) -> None: # pyright: ignore[reportIncompatibleMethodOverride]
47 await self.command( auxdata )
49 async def prepare( self, exits: __.ctxl.AsyncExitStack ) -> _core.Globals:
50 auxdata_base = await super( ).prepare( exits )
51 nomargs = {
52 field.name: getattr( auxdata_base, field.name )
53 for field in __.dcls.fields( auxdata_base )
54 if not field.name.startswith( '_' ) }
55 return _core.Globals( display = self.display, **nomargs )
58def execute( ) -> None:
59 ''' Entrypoint for CLI execution. '''
60 config = (
61 __.tyro.conf.EnumChoicesFromValues,
62 __.tyro.conf.HelptextFromCommentsOff,
63 )
64 try: __.asyncio.run( __.tyro.cli( Application, config = config )( ) )
65 except SystemExit: raise
66 except BaseException:
67 # TODO: Log exception.
68 raise SystemExit( 1 ) from None