python-click Questions
3
I am working on a small command line tool using Python 2 and click. My tool either needs to write a value, read it, or do not change it. It would be nice if I could do the following:
mytool --r0=0...
Gaberlunzie asked 23/11, 2016 at 0:15
1
Is it possible to specify two input types for a click.option, one of which the supplied value has to be in?
In a normal python function with typing, I'd declare it like so:
from typing import Union...
Shoat asked 30/3, 2021 at 17:21
2
Solved
I have recently found the click library (http://click.pocoo.org/6/) and I love it.
I am trying to figure out if it is possible to create an alias for the --help option which shortcuts to the help...
Fenrir asked 9/12, 2015 at 15:14
2
Solved
I am working on a command-line shell, and I'm trying to test some functions that parse command arguments.
parser.py:
import shlex
import click
def process_cmd(args, called_self=False):
result = ...
Elliellicott asked 28/11, 2019 at 20:53
2
Solved
I'm having a conundrum with the Python Click library when parsing some CLI options.
I would like an option to act as a flag by itself, but optionally accept string values. E.g.:
$ myscript ⇒ opt...
Veiled asked 18/3, 2020 at 14:50
5
Solved
Here is a simple example of click usage that causes pylint error:
@click.command()
@click.option('--option', is_flag=True)
def foo(option):
click.echo(option)
foo()
foo receives no arguments s...
Kame asked 5/4, 2018 at 19:35
5
I have a function which is wrapped as a command using click. So it looks like this:
@click.command()
@click.option('-w', '--width', type=int, help="Some helping message", default=0)
[... some othe...
Considered asked 5/2, 2018 at 9:40
5
Solved
Is it possible to do something like this with Python Click?
@click.command(name=['my-command', 'my-cmd'])
def my_command():
pass
I want my command lines to be something like:
mycli my-command
...
Derayne asked 9/10, 2017 at 8:29
3
Solved
CliRunner lists no parameter to provide a context in its documentation.
The following should qualify as a minimum working example.
The real problem is a bit different.
It could be solved by moving...
Smaze asked 5/11, 2016 at 21:25
6
Solved
Say my CLI utility has three commands: cmd1, cmd2, cmd3
And I want cmd3 to have same options and flags as cmd1 and cmd2. Like some sort of inheritance.
@click.command()
@click.options("--verbose"...
Wertheimer asked 21/10, 2016 at 17:13
7
Creating custom commands in flask needs access to the app, which is generally created in app.py like this:
import click
from flask import Flask
app = Flask(__name__)
@app.cli.command("create-use...
Seigler asked 25/7, 2019 at 13:9
5
Solved
I want to have a command line tool with a usage like this:
$ program <arg> does something, no command name required
$ program cut <arg>
$ program eat <arg>
The Click code would...
Brunei asked 28/8, 2018 at 8:34
2
Solved
This question is about the click package:
Long text of help is not being displayed as desired.
I tried using /b as well but does not seem to affect much.
cmd and powershell both have different res...
Overcautious asked 9/4, 2019 at 5:21
4
Solved
I'm using the Python Click library for my command-line interface. I'd like to have a command that takes multiple key value pairs. I'm flexible on the api. For example
my_cli my_command FOO=1 BAR=2...
Orpiment asked 3/7, 2018 at 23:32
5
Solved
I have two Python CLI tools which share a set of common click.options. At the moment, the common options are duplicated:
@click.command()
@click.option('--foo', is_flag=True)
@click.option('--bar'...
Counterspy asked 27/4, 2018 at 11:22
2
Solved
I just stumbled upon a piece of code that defines a click option as such:
@click.option(
"-s",
"--status",
default=True,
is_flag=True,
help="Show status",
)
Does this means that the status ...
Remediless asked 28/12, 2018 at 10:54
4
Solved
I define my Flask application using the app factory pattern. When using Flask-Script, I can pass the factory function to the Manager. I'd like to use Flask's built-in Click CLI instead. How do I us...
Prescription asked 12/3, 2017 at 23:15
6
Solved
I want to call a python script through the command line with this kind of parameter (list could be any size, eg with 3):
python test.py --option1 ["o11", "o12", "o13"] --option2 ["o21", "o22", "o2...
Joslyn asked 4/12, 2017 at 11:5
1
Solved
How to tell whether an argument in click is coming from the user or is the default value?
For example:
import click
@click.command()
@click.option('--value', default=1, help='a value.')
def hello(...
Batha asked 20/2, 2023 at 17:39
1
My Python script has a class named Command. I want to call my class' method as a CLI command (something like python cli-comand.py net get-public-ip).
I used the Python click library, but when I tri...
Must asked 16/7, 2020 at 9:19
2
Solved
I'm using Click to build a CLI interface. Click offers dynamic defaults for prompts, which is great. Also this example gives some insights on how to implement dynamic defaults using a custom click-...
Flannery asked 14/8, 2018 at 17:12
4
Solved
Is there an equivalent to argparse's nargs='*' functionality for optional arguments in Click?
I am writing a command line script, and one of the options needs to be able to take an unlimited number...
Mendiola asked 22/1, 2018 at 23:16
3
Solved
When using click I know how to define a multiple choice option. I also know how to set an option as a required one. But, how can I indicate that an option B is required only if the value of option ...
Sacculate asked 27/9, 2017 at 6:32
3
Solved
I want to implement mycommand --version using python click. I have something like this working but it feels kinda clunky.
@click.group(invoke_without_command=True, no_args_is_help=True)
@click.pas...
Newlin asked 1/11, 2019 at 23:5
2
Solved
Given the following program:
#!/usr/bin/env python
import click
@click.command()
@click.argument("arg")
@click.option("--opt")
@click.option("--config_file", type=click.Path())
def main(arg, opt,...
Dekameter asked 22/9, 2017 at 7:7
1 Next >
© 2022 - 2024 — McMap. All rights reserved.