pyinfra icon indicating copy to clipboard operation
pyinfra copied to clipboard

Add informations on cli output about module when fact or operation was not found

Open maisim opened this issue 1 year ago • 1 comments

Hello folks,

If the operation or fact was not found, it will display the ones available, and if no one is available, Warn the user about the possibility that he have a py file or a folder with the same name as the module

If you have a directory wich have the same name as the pyinfra module you want to use, pyinfra will try to look inside form the operations/facts (wich seems to be the wanted behavior)

So I added a message to inform about this possibility if the module/fact is not found:

find . -name incus
./incus
pyinfra inventory.py --debug --limit=lx1 fact incus.IncusProfiles
--> pyinfra error: No such attribute in module incus: IncusProfiles
No facts found. Maybe you have a file or folder named `incus` in the current folder ?

In the same time I added this:

pyinfra inventory.py --debug --limit=lx1 fact incus.IncusProfilesNOEXIST
--> pyinfra error: No such attribute in module incus: IncusProfilesNOEXIST
Available facts in module are: IncusInstances, IncusProfiles, IncusTestFact

This is a suggestion, tell me what you think.

maisim avatar Nov 22 '24 14:11 maisim

It does not work as expected for operations in case of misspelling

maisim avatar Nov 25 '24 08:11 maisim