Python click: Make some options hidden
Asked Answered
H

2

19

I'm using click to build a CLI in Python. I have several options to the command I'm defining, and I want some of them to be hidden in --help. How can I do that?

Hyunhz answered 17/12, 2015 at 12:16 Comment(0)
M
18

Yes, you can. Use

@click.option(..., hidden=True)

The feature is now (March 2019) in the stable release of Click.

Please note: In the first implementation the functionality was realised with a parameter show=False, but is now done with hidden=True.

Microseism answered 26/3, 2019 at 23:48 Comment(3)
For info, you can also do the same on commands: @click.command(..., hidden=true)Kaye
Documentation link: click.palletsprojects.com/en/7.x/api/…Naevus
NB. This also works in Typer, which is based on Click.Zaccaria
C
3

This feature is on the verge of being included in click, you can follow the development here:

https://github.com/mitsuhiko/click/pull/500

Cervantes answered 15/1, 2016 at 17:32 Comment(1)
The pull request still isn't available as of 2016-11-11, but according to comments should be in the 7.x version when that comes out.Berard

© 2022 - 2024 — McMap. All rights reserved.