Skip to content

Commit

Permalink
dep
Browse files Browse the repository at this point in the history
  • Loading branch information
m000 committed Nov 5, 2023
1 parent 675bd83 commit 2f50f51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/jj2cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from . import __version__, filters, parsers
from .customize import CustomizationModule
from .defaults import CONTEXT_FORMATS
from .defaults import CONTEXT_FORMATS, DEPENDENCIES_OUTPUT_FORMATS
from .render import Jinja2TemplateRenderer

# available log levels, adjusted with -v at command line
Expand Down Expand Up @@ -138,4 +138,27 @@ def render():

def dependencies():
""" CLI entry point for analyzing template dependencies. """
#version_info = (__version__, jinja2.__version__)
parser = argparse.ArgumentParser(
description='Analyze Jinja2 templates for dependencies.',
epilog='',
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
p_input = parser.add_argument_group('input options')
p_output = parser.add_argument_group('output options')
p_output_mode = p_output.add_mutually_exclusive_group()
### input options ###############################################
p_input.add_argument('templates', metavar='TEMPLATE', nargs='+',
type=argparse.FileType('r', encoding='utf-8'))
### output options ##############################################
p_output.add_argument('-f', '--format',
default='make', choices=sorted(DEPENDENCIES_OUTPUT_FORMATS),
help='Specify output format for dependencies.')
p_output_mode.add_argument('-o', metavar='outfile', dest='output_file',
help="Output to a file instead of stdout.")
p_output_mode.add_argument('--per-file', action='store_true', dest='per_file',
help='Produce one output file per input file.')

args = parser.parse_args()
print(args)
raise NotImplementedError("jj2dep has not yet been implemented.")
5 changes: 5 additions & 0 deletions src/jj2cli/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@
# Variables for parsing dataspecs.
DATASPEC_SEP = ':'
DATASPEC_COMPONENTS_MAX = 3

# Supported formats for outputting template dependencies.
DEPENDENCIES_OUTPUT_FORMATS = ['make', 'json', 'yaml', 'delim']
if yaml_load is None:
DEPENDENCIES_OUTPUT_FORMATS.remove('yaml')

0 comments on commit 2f50f51

Please sign in to comment.