j2cli icon indicating copy to clipboard operation
j2cli copied to clipboard

j2cli brokes drastically when `data` has no/invalid filename extensions

Open brlin-tw opened this issue 4 years ago • 0 comments

Reproduce

$ j2 template.j2 data
Traceback (most recent call last):
  File "/home/brlin/.local/bin/j2", line 8, in <module>
    sys.exit(main())
  File "/home/brlin/.local/pipx/venvs/j2cli/lib/python3.6/site-packages/j2cli/cli.py", line 206, in main
    sys.argv[1:]
  File "/home/brlin/.local/pipx/venvs/j2cli/lib/python3.6/site-packages/j2cli/cli.py", line 138, in render_command
    }[os.path.splitext(args.data)[1]]
KeyError: ''

Expected behavior

  • j2cli detect data type automatically
  • j2cli fails with a friendly message regard the issue (e.g., Error: _data_ must have the following filename extensions: ...)

Version

j2cli 0.3.10, Jinja2 2.11.1
installed via pipx

brlin-tw avatar Apr 15 '20 16:04 brlin-tw