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