Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Alternative to click types #70

Closed
Mitmischer opened this issue Jul 12, 2021 · 1 comment
Closed

Alternative to click types #70

Mitmischer opened this issue Jul 12, 2021 · 1 comment

Comments

@Mitmischer
Copy link

In click, I could specify the type of an option, like this: 1 with the types specified here: 2 3 .

This is expecially useful for files with the click.File class.
cloup.File does not exist; Also it looks to me as if the whole typing functionality from click was not adopted. Are there alternatives to achieve similar functionality in cloup?

@Mitmischer Mitmischer added the enhancement New feature or request label Jul 12, 2021
@janluke
Copy link
Owner

janluke commented Jul 12, 2021

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). I'll add this to the installation instructions.


Currently, there's no plan to re-export Click types from Cloup itself. But it's something I've thoght about in the past. Maybe I'll open an issue to keep that in mind because types are usually the only reason I import click.

@janluke janluke removed the enhancement New feature or request label Jul 12, 2021
@janluke janluke closed this as completed Jul 12, 2021
Repository owner locked and limited conversation to collaborators Jul 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants