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

Removal of click dependency #234

Open
lewer opened this issue Jul 28, 2023 · 3 comments
Open

Removal of click dependency #234

lewer opened this issue Jul 28, 2023 · 3 comments

Comments

@lewer
Copy link
Contributor

lewer commented Jul 28, 2023

Hi,

The click library is used in panflute, but only here:

@click.command(help=help_str)
@click.argument('filters', nargs=-1)
@click.option('-w', '-t', '--write', '--to', 'to', type=str, default=None,
help='Output format passed to Pandoc (and filters).')
@click.option('--dir', '-d', 'search_dirs', multiple=True,
help="Search filters in provided directories: `-d dir1 -d dir2`.")
@click.option('--data-dir', is_flag=True, default=False,
help="Search filters in default user data directory listed in `pandoc --version` " +
"(in it's `filters` subfolder actually). It's appended to the search list.")
@click.option('--no-sys-path', 'sys_path', is_flag=True, default=True,
help="Disable search filters in python's `sys.path` (without '' and '.') " +
"that is appended to the search list.")

This can be easily replaced with standard lib's argparse, and then click could be removed. It would be one less dependency.

Do you agree with a PR proposing this?

@sergiocorreia
Copy link
Owner

I've gotten used to click in other packages (easier than argparse) so I have a slight preference for relying on it.

That said, is there something that makes you prefer a click-less approach?

@lewer
Copy link
Contributor Author

lewer commented Jul 29, 2023

I have nothing against click and use it also in some projects. If you have a complex CLI with for instance subcommands and don't want the hassle of doing it with argparse, why not using click.

But here there's only a single command, with a few options. It would easily translate to argparse syntax, and would achieve the same behavior. The benefit is that you reduce the external dependencies of panflute; users who install panflute (like me :-)) don't have to install click also, click can be removed from the CI, etc. It's not a huge improvement, but if it doesn't cost anything...

@mfhepp
Copy link

mfhepp commented Aug 1, 2023

In the light of supply-chain attacks on Python dependencies, simplifying the dependency graph is generally a good thing. But as for Click, I tend to see the benefits outweigh the costs. CLI interfaces with Click (or Typer, which is an even nicer wrapper around Click) are so much more readable than argparse stuff.

And a panflute-based project will have additional dependencies in a requirements.txt or environment.yaml anyway.

So I would argue for a readable and maintainable CLI implementation and hence for keeping the dependency. But no strong opinion either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants