New switch for --dockerfile
audunsol opened this issue Β· comments
Dockerfiles are nicely formatted when running rich Dockerfile
. Thanks! π
But when the dockerfile is named something else, or when its ouput comes from stdin, it seems to not be possible to request Dockerfile rendering, as there is no --dockerfile
flag (similar to how it works for --markdown
).
What is currently working (i.e. gives nice color coded output):
rich Dockerfile
What is currently not working (renders the file just like cat
):
# Named something else than just Dockerfile:
rich Dockerfile.service1
# When used as "file extension":
rich service1.Dockerfile
# When coming from stdin:
cat Dockerfile | rich -
# Since previous example might just looks silly, here is an example where we do "useful" stuff before passing it to rich-cli:
cat Dockerfile | sed 's/FROM \S*/FROM node:16/gi' | rich -
After reading a bit further, and visiting https://pygments.org/docs/lexers/#pygments.lexers.configs.DockerLexer I now realized how the --lexer
option works, and that it 100% solves my problem (and all similar problems with other file types in the same go) π€¦ββοΈ
For completeness, the modified versions of the commands above, that does what I want is:
# Named something else than just Dockerfile:
rich --lexer=docker Dockerfile.service1
# When used as "file extension":
rich --lexer=docker service1.Dockerfile
# But if using the file extension `docker`, as described in https://pygments.org/docs/lexers/#pygments.lexers.configs.DockerLexer, it will be recognized, and I can avoid that option:
mv service1.Dockerfile service1.docker
rich service1.docker
# When coming from stdin:
cat Dockerfile | rich - --lexer=docker
# The other stdin example, using short-alias for variation:
cat Dockerfile | sed 's/FROM \S*/FROM node:16/gi' | rich - -x docker
Closing this now. So sorry about the noise!
Thanks again for a great tool - it just became even better for me after understanding how to use this option!