Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
77 views

I am having trouble using add_argument's dest parameter with positional arguments. The reason I want this is that I use nargs='*' and it makes sense to me to have the argument name be singular so that ...
Dominik Kaszewski's user avatar
0 votes
1 answer
52 views

I derive some settings from my parser that I latter store on disk to be reloaded again, during the reload I want to overwrite some values but keep the first ones, similar to new default values. I want ...
Daraan's user avatar
  • 5,136
1 vote
2 answers
81 views

When I run my FastAPI app with the Uvicorn command, the command line args are not recognized: (env) mydir$ uvicorn main:app --port 8000 --host 0.0.0.0 --reload ... uvicorn: error: unrecognized ...
engineer-x's user avatar
  • 3,395
0 votes
0 answers
56 views

I can run a script on the command line with an argument either as the bare "script.py arg1" or I can run it as "python script.py arg1". Both work until I use argparse for command ...
wgw's user avatar
  • 601
1 vote
3 answers
139 views

First of all, I cannot share the original code so I apologize in advance if the example used does not make sense. I also know the code I present has some issues and will not run as it is, but it is ...
Jaime 's user avatar
  • 143
1 vote
1 answer
98 views

I have a CLI tool for managing Docker containers. Here's my current parser setup: def create_parser(): parser = argparse.ArgumentParser(description="Docker container manager") ...
Izaan's user avatar
  • 145
0 votes
1 answer
77 views

I need to process command-line options from my Python script that correspond to the syntax tesy.py [-h] [-a [-b]] (This is just a simplistic example illustrating the problem; in reality my script has ...
bontchev's user avatar
  • 578
3 votes
0 answers
53 views

Scenario: Flags -a 'thing1' and/or -b 'thing2' can be provided. If either is provided, 'sub' flags -c and/or -d can be provided. * If -a and/or -b are not provided, -c and/or -d should be ignored/...
AlexH's user avatar
  • 73
0 votes
1 answer
287 views

Using the Java port of the Argparse4j library, how can I pass a list as a cli argument? I know there are answers to this querstion in Python, but am looking for a Java example. For example how can I ...
jjbskir's user avatar
  • 11.3k
0 votes
0 answers
86 views

I'm type hinting a codebase that uses argparse to parse command-line arguments, and in this part of the code there are some functions that make operations on the value returned by argparse....
Newbyte's user avatar
  • 3,957
0 votes
1 answer
64 views

I'm trying to check if an optional argument is supplied by the user but I want to set its default value if it is not supplied. If I try to use if statement by exploiting None, the default in help ...
Divyajyoti's user avatar
0 votes
1 answer
179 views

I have a python package with a lot of sub commands and sub-sub commands. It is organized somewhat like this: main.py import argparse from sum import prepare_arg_parser as prepare_sum_parser from sub ...
Hugal31's user avatar
  • 1,828
2 votes
1 answer
76 views

I have this snippet for illustrative purpose that doesn't work at all. #!/usr/bin/env python3 import argparse parser = argparse.ArgumentParser() parser.add_argument("--action", nargs=&...
Philippe's user avatar
  • 2,126
0 votes
1 answer
152 views

I have the following python code set up, in which the program would return "something" whenever the user pass -- as an argument: #script.py import argparse parser = argparse.ArgumentParser(...
Epimu Salon's user avatar
0 votes
0 answers
121 views

I have the following bash script that I source in my root directory: ROOT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" eval &...
NiklasMan's user avatar
1 vote
2 answers
66 views

I'm using ArgumentParser to document the usage of a complicated program. Since the program has several long lists of capabilities, it requires several --help arguments. My current ArgumentParser looks ...
Martín Fixman's user avatar
3 votes
3 answers
2k views

I have an enum: from enum import auto, Enum class MyEnum(Enum): ONE = auto() TWO = auto() THREE = auto() and I want to use it as an argument with argparse. To be more specific, I want to ...
Shai Avr's user avatar
  • 1,420
1 vote
2 answers
110 views

I have a function that sets what arguments can be passed to a command line when calling on a function, using argparse: def parse_arguments(args): parser = argparse.ArgumentParser(usage=...
user21641220's user avatar
-2 votes
2 answers
157 views

I am trying to figure out how to incorporate argparse into a python function I have created that accepts two arguments, so that it is executable in the command line. For example in this function below:...
NicoMane's user avatar
0 votes
2 answers
52 views

I want a script to save all arguments (whether provided or populate from defaults or read from a text file) to a text file in such a format that I can re-run the script using fromfile_prefix_chars ...
Edgar H's user avatar
  • 1,559
-1 votes
1 answer
82 views

I want to write a program in Python that gets args of unspecified number and type. I can do this with argparse as follows: parser = argparse.ArgumentParser() parser.add_argument('args', help='Help', ...
ArianNa's user avatar
  • 53
0 votes
3 answers
78 views

i have an ArgumentParser with sub-parsers. Some flags are common for all sub-parsers, and I would like to be able to specify them either before or after the sub-command, or even mix before and after (...
umläute's user avatar
  • 32.2k
0 votes
1 answer
49 views

I'm using the argparse Python module in a script that looks like this: import argparse def get_info(line: str) -> tuple: print(line.split("|")) def main(): p = argparse....
user avatar
0 votes
2 answers
257 views

Python's argparse module is a powerful tool for parsing script command line arguments. The problem is that it expects the args to be separated by spaces. Is there a way to let argparse know I am using ...
ysap's user avatar
  • 8,241
0 votes
0 answers
41 views

with argparse, is it possible to check whether the first positional argument has been entered: import argparse if __name__ == "__main__": parser = argparse.ArgumentParser() parser....
laloune's user avatar
  • 693

1
2 3 4 5
73