Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python short and long argument parser

I'd like to add some command line switches to my script, to which I use the argparse.

The related part of my script so far looks like:

import argparse

parser = argparse.ArgumentParser(prog="Hola python",description="Hola")
parser.add_argument('-i', '--input', help="helpppping")
parser.print_help()

However this results in:

usage: Hola python [-h] [-i INPUT]

Hola

optional arguments:
-h, --help            show this help message and exit
-i INPUT, --input INPUT
                    helpppping

My concerns is with this row

-i INPUT, --input INPUT

This should looks like

 -i, --input         helppppping

I saw this question, and read this part of the manual, and all seems good but still not formatted well.

I obviously miss something just don't know what.

like image 380
SecThor Avatar asked Nov 07 '22 10:11

SecThor


1 Answers

try this

 parser.add_argument('-i', '--input', metavar='', help='helping')
like image 116
om tripathi Avatar answered Nov 15 '22 11:11

om tripathi