Coverage for sources/agentsmgr/commands/detection.py: 58%
12 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-13 00:43 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-13 00:43 +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 for detecting Copier configuration in target directories. '''
24from . import __
25from . import base as _base
28_scribe = __.provide_scribe( __name__ )
31class DetectCommand( __.appcore_cli.Command ):
32 ''' Detects and displays current Copier configuration for agents. '''
34 source: __.typx.Annotated[
35 __.Path,
36 __.tyro.conf.arg(
37 help = "Target directory to search for configuration.",
38 prefix_name = False ),
39 ] = __.dcls.field( default_factory = __.Path.cwd )
41 @_base.intercept_errors( )
42 async def execute( self, auxdata: __.appcore.state.Globals ) -> None: # pyright: ignore[reportIncompatibleMethodOverride]
43 ''' Detects agent configuration and displays formatted result. '''
44 if not isinstance( auxdata, __.Globals ): # pragma: no cover
45 raise __.ContextInvalidity
46 _scribe.info( f"Detecting agent configuration in {self.source}" )
47 configuration = await _base.retrieve_configuration( self.source )
48 _scribe.debug( f"Found configuration: {configuration}" )
49 result = __.ConfigurationDetectionResult(
50 target = self.source,
51 coders = tuple( configuration[ 'coders' ] ),
52 languages = tuple( configuration[ 'languages' ] ),
53 project_name = configuration.get( 'project_name' ),
54 )
55 await __.render_and_print_result(
56 result, auxdata.display, auxdata.exits )