2020from inspect import isfunction
2121from typing_extensions import Annotated
2222
23+ from dotware import config
2324from dotware .config import *
2425from dotware import __pkg_name__ , __version__
2526from dotware .registry import *
@@ -78,10 +79,16 @@ def showComponents(type: Annotated[str, typer.Argument(help="Component Type")]):
7879 compdir = COMPLETIONS
7980 case 'functions' :
8081 compdir = FUNCTIONS
82+ case 'packages' :
83+ compdir = PACKAGES
8184 case 'plugins' :
8285 compdir = PLUGINS
86+ case 'scripts' :
87+ compdir = SCRIPTS
88+ case 'stacks' :
89+ compdir = STACKS
8390 case _:
84- logger .error (f"Unknown component type '{ type } '. Valid types are: { ', ' .join (SELECTABLE_TYPES )} " )
91+ logger .error (f"Unknown component type '{ type } '. Valid types are: { ', ' .join ([ t [ 0 ] for t in COMPONENT_TYPES ] )} " )
8592 raise typer .Exit (code = 1 )
8693
8794 if not compdir .exists ():
@@ -92,7 +99,26 @@ def showComponents(type: Annotated[str, typer.Argument(help="Component Type")]):
9299 i = 1
93100 files = [f .name for f in compdir .iterdir () if f .is_file ()]
94101 for file in files :
95- pass
102+ try :
103+ compfile = compdir / file
104+ if not compfile .exists ():
105+ logger .error (f"Component file '{ compfile } ' does not exist." )
106+ continue
107+ if type in SELECTABLE_TYPES :
108+ status = Registry ._status (compfile )
109+ if status == 0 :
110+ status_symbol = SYMBOL_SUCCESS
111+ elif status == 1 :
112+ status_symbol = " "
113+ else :
114+ status_symbol = SYMBOL_ERROR
115+ else :
116+ status_symbol = " "
117+ logger .info (f"{ i } . { status_symbol } { file } " )
118+ i += 1
119+ except Exception as e :
120+ logger .error (f"Error processing file '{ file } ': { e } " )
121+ raise
96122
97123 except Exception as e :
98124 logger .error (f"Failed to show components of type '{ type } ': { e } " )
@@ -131,6 +157,7 @@ def installPackage(name: Annotated[str, typer.Argument(help="Package Name")]):
131157 preinstall = f"{ name } ::pre_install"
132158 installfnc = f"{ name } ::install"
133159 postinstall = f"{ name } ::post_install"
160+ configfnc = f"{ name } ::config"
134161 if not pkgfile .exists ():
135162 logger .error (f"Package directory '{ pkgfile } ' does not exist." )
136163 raise typer .Exit (code = 1 )
@@ -166,6 +193,9 @@ def installPackage(name: Annotated[str, typer.Argument(help="Package Name")]):
166193 else :
167194 logger .info (f"Post-installation hook executed successfully for package '{ name } '." )
168195
196+ if grepFile (pkgfile , configfnc ):
197+ logger .info (typer .style (f"Package also includes configuration hook" , fg = config .COLOR_WARNING , bold = True ))
198+
169199 except Exception as e :
170200 logger .error (f"Failed to install package '{ name } ': { e } " )
171201 raise
0 commit comments