Questions tagged [python-click]

Click is a Python library for creating command line interfaces.

Click is a Python package for creating command line interfaces in a composable way with as little code as necessary. It is the "Command Line Interface Creation Kit". It is highly configurable but comes with sensible defaults out of the box.

Click supports:

  • arbitrary nesting of commands
  • automatic help page generation
  • lazy loading of sub-commands at runtime

Links

482 questions
0
votes
1 answer

Python click module for creating a CLI

I am using python click module to create a CLI. The fact is that I want to have category commands with arguments, for example: myawesomecli env info myawesomecli env clean myawesomecli env ... myawesomecli database create-table myawesomecli…
hosselausso
  • 967
  • 1
  • 10
  • 28
0
votes
1 answer

Click error "takes no arguments" in main()

I am having issues which I believe are due to click. I am trying to run this code and I keep running into the same traceback TypeError stating an argument is being passed to main(). #!/usr/bin/python # -*- coding: utf-8 -*- import sys import…
Ethan
  • 707
  • 3
  • 8
  • 17
0
votes
1 answer

How to share a variable globally in python program?

I'm working on a program which has a config. I need to use a different config for the tests and the normal running of the program. I manage all the software and tests using a manage.pyscript and all the tests are under python manage.py test ... …
Alexis Benoist
  • 2,400
  • 2
  • 17
  • 23
0
votes
2 answers

Determine final character in bash tabcompletion

I'm looking to determine whether the final character is a space, or not. $ mycli fl[TAB] # no space flag flare $ mycli flare [TAB] # yes space A B C D Reason If it is a space, then the each argument is used to determine completion hints, but if…
Marcus Ottosson
  • 3,241
  • 4
  • 28
  • 34
-1
votes
0 answers

click library not recognizing my option on the terminal

I'm trying to set an option to a function in the click library of python. when I pass the argument to the function and run it, it never works. it says that the option is not defined. here is the whole code: mport sys import paramiko as pk import…
-1
votes
1 answer

Error 'No such file or directory' when use click

I'm using click 8.1.3 to parse my command,and my cli.py is like this: @click.option('--output_dir', default=os.curdir, help='when outdated is true,choose directory which you want to put your cache file') @click.option('--cache_dir',…
forestbat
  • 453
  • 4
  • 10
-1
votes
1 answer

Python Click module treats options as arguments and errors out

What am I doing wrong here? My Click script has no arguments but has multiple options. My script is as…
streetsoldier
  • 1,259
  • 1
  • 14
  • 32
-1
votes
1 answer

How to limit a string option parameter length in python click

I am implementing a python CLI with Click. I wait to add an optional string parameter --name but I want to its length. Is there a native way to do that with click? e.g. some option to pass to @option
Martin Faucheux
  • 884
  • 9
  • 26
-1
votes
1 answer

join() argument must be str, bytes, or os.PathLike object, not 'NoneType'

I am making a CLI tool using python and click. I have a command called ext that has two options --type and --path and then another command ext. The function organizes the files in the specified path based on the extension specified in the given…
Rohith Nambiar
  • 2,957
  • 4
  • 17
  • 37
-1
votes
1 answer

How to pass only one option in Python Click

I am writing a command line interface using python click library and I want to enforce users to pass only one option at a time to the click command and it should return an error if user pass both the options at the same time. Is there a way to do…
nad87563
  • 3,672
  • 7
  • 32
  • 54
-1
votes
1 answer

Running Python Click Command as Root

I am trying to run my a command (generated from Python's click package - https://click.palletsprojects.com/en/7.x/) with ROOT privileges (through the sudo command) enter image description here I can't seem to find a way to do it, can anyone provide…
cyberjj999
  • 27
  • 1
  • 6
-1
votes
1 answer

click not detecting commands in a group

I have the following config: mymodule/__init__.py: @click.group() @click.option('--env', required=True, type=str, help='Environment: t1, t2, t22,..., s, p', default=lambda: getenv("APP_ENV")) @click.option('--load-type', help='Load type',…
s5s
  • 11,159
  • 21
  • 74
  • 121
-1
votes
1 answer

Get command line args

I'm trying to get the command line args before they get processed by click: print(click.get_current_context().find_root().params) This just prints empty eventhough I gave script cmd1 cmd2 --arg1 --arg2 3. I'm trying to get a string or list that…
Oliver
  • 27,510
  • 9
  • 72
  • 103
-1
votes
1 answer

Creating a click command that accepts two different sets of arguments

Through the python package click I have legacy code that looks as followed on the command line: toolName toolCommand arugment I have updated the legacy code for the command to accept three arguments now: toolName toolCommand arugment1 argument2…
-1
votes
1 answer

Build command line tool using click package

I am new to using click package if I give one to two commands and run it its not giving output, please look at my code and suggest what I can do. import click @click.group() @click.option('--removedigits',default=False,help='remove digits from…
as_1234
  • 11
1 2 3
32
33