Now my script calls via:
python resylter.py -n *newfile* -o *oldfile*
code looks like:
parser.add_argument('-n', '--newfile', help='Uses only with -o argument. Compares inputed OLD (-o) file with previous run results with NEW(-n) output.xml file with actual run results')
parser.add_argument('-o', '--oldfile', help='Uses only with -n argument. Compares inputed OLD (-o)  file with previous run results with NEW(-n) output.xml file with actual run results')
and some actions
How i can edit it to use like this?:
python resylter.py -n *newfile* *oldfile*
sys.argv[-1] didn't works
Use nargs=2:
parser.add_argument(
    '-c',
    '--compare',
    nargs=2,
    metavar=('newfile', 'oldfile'),
    help='Compares previous run results in oldfile with current run results in newfile.',
    )
args = parser.parse_args()
newfile, oldfile = args.compare
Also adding metavar=('newfile', 'oldfile') improves the help text if you run resylter.py -h.
Docs: nargs, metavar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With