Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added j2lint version, verbose logging options and repository references. #18

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pip install git+https://github.com/aristanetworks/j2lint.git
To get started with j2lint code, clone the Jinja2 Linter project on your system:

```
git clone https://gitlab.aristanetworks.com/ansible-team/jinja2-linter
git clone https://github.com/aristanetworks/j2lint.git
```

### Prerequisites
Expand Down
34 changes: 32 additions & 2 deletions j2lint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def create_parser():
action='store_true', help='accept template from STDIN')
parser.add_argument('--log', default=False,
action='store_true', help='enable logging')
parser.add_argument('-ver', '--version', default=False,
action='store_true', help='Version of j2lint')
parser.add_argument('-stdout', '--vv', default=False,
action='store_true', help='stdout logging')
parser.add_argument('-sout', '--vvv', default=False,
action='store_true', help='stdout logging')
return parser


Expand Down Expand Up @@ -92,13 +98,32 @@ def run(args=None):
options = parser.parse_args(args if args is not None else sys.argv[1:])

# Enable logs
if not options.log:

if not options.log and not options.vv and not options.vvv:
logging.disable(sys.maxsize)
else:
elif options.log:
add_handler(logger)
# Enable debug logs
if options.debug:
logger.setLevel(logging.DEBUG)
elif options.vv:
# Enable logs on console
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[
logging.StreamHandler(sys.stdout)
]
)
elif options.vvv:
# Enable debug logs on console
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[
logging.StreamHandler(sys.stdout)
]
)

logger.debug("Lint options selected {}".format(options))

Expand All @@ -125,6 +150,11 @@ def run(args=None):
logger.debug(rules)
return 0

# Version of j2lint
if options.version:
print(f"Jinja2-Linter Version {VERSION}")
return 0

# Print help message
if not file_or_dir_names:
parser.print_help(file=sys.stderr)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
description=DESCRIPTION.split('\n')[0],
long_description=long_description,
long_description_content_type="text/markdown",
url="https://gitlab.aristanetworks.com/ansible-team/jinja2-linter",
url="https://github.com/aristanetworks/j2lint.git",
project_urls={
"Bug Tracker": "https://gitlab.aristanetworks.com/ansible-team/jinja2-linter/issues",
"Bug Tracker": "https://github.com/aristanetworks/j2lint/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
Expand Down