Skip to content

Alternative to click types #73

Answered by janluke
Mitmischer asked this question in Q&A
Jul 12, 2021 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

UPDATE(v0.10.0): Click types are now re-exported by Cloup, so you don't need to import Click.


Cloup is meant to be used in tandem with Click, it's not a replacement for Click. You can use Click types as you do with Click:

import click
import cloup

@cloup.command()
@cloup.option('-o', '--out', type=click.File(...))
def f(out):
    ...

More in general, what you can do with Click, you can do with Cloup too, because Cloup commands are Click commands (subclasses) and Cloup parameters are Click parameters.

Note that, even though Cloup has Click as a dependency, you should explicitly add Click to your requirements too because you are gonna use it directly in your code (usually only for types).…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by janluke
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@janluke
Comment options

@Mitmischer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #70 on July 12, 2021 14:29.