mjml-python icon indicating copy to clipboard operation
mjml-python copied to clipboard

Add Cli

Open AndPuQing opened this issue 1 year ago • 2 comments

close https://github.com/mgd020/mjml-python/issues/24

Note: watch mode not implemented

AndPuQing avatar Feb 28 '24 08:02 AndPuQing

Thanks for the PR.

I have some questions:

  • How is this run from the command line by users who install the package?
  • What does the --help output look like? Similar to the npm package's?

Can you please also add these changes:

  • Update README.md docs with info about running command line and arguments
  • Add tests for the new rust code

mgd020 avatar Feb 29 '24 00:02 mgd020

  • How is this run from the command line by users who install the package?

When users install the package, I utilize Python package scripts for command-line execution. For more details, please refer to creating-executable-scripts. Users simply need to run pip install mjml-python, and the mjml command will be added to the environment path. Essentially, a file is added at /home/happy/micromamba/bin/mjml with the following content:

#!/home/happy/micromamba/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from mjml import run_cli
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(run_cli())
  • What does the --help output look like? Similar to the npm package's?

Regarding the --help output, during the development process, I took inspiration from the Node.js mjml interface. Users can expect the following output when running mjml --help:

➜ mjml --help                                                                                                                                                   (base)
Usage: Usage: mjml [OPTIONS] [INPUT]...

Arguments:
  [INPUT]...  Path to your mjml file

Options:
  -m, --migrate                                  Migratie the input
  -c, --certify                                  Certify(Validate) the input
  -s, --stdout                                   Render and redirect to stdout
  -o, --output <OUTPUT>                          Render and redirect to file
  -w, --watch                                    Watch for changes and re-render
      --disable-comments                         Remove comments from html output
      --social-icon-origin <SOCIAL_ICON_ORIGIN>  Base url for social icons
  -v, --verbose...                               Increase logging verbosity
  -q, --quiet...                                 Decrease logging verbosity
  -h, --help                                     Print help
  -V, --version                                  Print version

Can you please also add these changes:

Done.

AndPuQing avatar Feb 29 '24 08:02 AndPuQing