forked from ovh/pci-test
26 lines
545 B
Python
26 lines
545 B
Python
import argparse
|
|
import sys
|
|
|
|
VALORI_AMMESSI = {"toto", "tata", "titi"}
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
|
'-t', '--target',
|
|
nargs='+',
|
|
choices=VALORI_AMMESSI,
|
|
help="Specifica da 1 a 3 valori tra: toto, tata, titi.",
|
|
required=True
|
|
)
|
|
|
|
# Esegui parsing
|
|
args = parser.parse_args()
|
|
|
|
# Verifica massimo 3 valori
|
|
if len(args.target) > 3:
|
|
print("Errore: puoi fornire **al massimo 3** valori tra 'toto', 'tata' e 'titi'.", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
# Tutto OK
|
|
print("Valori accettati:", args.target)
|