feat: add new CLI flag --no-role-detection to parse loose files (#135)

Co-authored-by: P. Tomas <ptomas@astr-ptomas.edcs.fr>
This commit is contained in:
ptomas-adacis 2021-07-27 21:32:39 +02:00 committed by GitHub
parent 6941fdf448
commit e07184fe6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -68,6 +68,14 @@ class AnsibleDoctor:
parser.add_argument(
"--version", action="version", version="%(prog)s {}".format(__version__)
)
parser.add_argument(
"-n",
"--no-role-detection",
dest="no_role_detection",
action="store_true",
default=None,
help="disable role detection"
)
return parser.parse_args().__dict__
@ -82,10 +90,13 @@ class AnsibleDoctor:
except ValueError as e:
self.log.sysexit_with_message("Can not set log level.\n{}".format(str(e)))
if config.is_role:
self.logger.info("Ansible role detected")
if not config.config["no_role_detection"]:
if config.is_role:
self.logger.info("Ansible role detected")
else:
self.log.sysexit_with_message("No Ansible role detected")
else:
self.log.sysexit_with_message("No Ansible role detected")
self.logger.info("Ansible role detection disabled")
self.logger.info("Using config file {}".format(config.config_file))

View File

@ -97,6 +97,12 @@ class Config():
"file": True,
"type": environs.Env().list
},
"no_role_detection": {
"default": False,
"env": "NO_ROLE_DETECTION",
"file": True,
"type": environs.Env().bool
},
}
ANNOTATIONS = {