1
0
forked from ovh/pci-test

fix/improvement to python files

This commit is contained in:
dmagro 2025-05-01 20:47:43 +02:00
parent cd81e92142
commit 012b0bf04c
3 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import sys
frase = " ".join(sys.argv[1:])
print("Hai scritto:", frase)
argv = " ".join(sys.argv[1:])
print("You've written:", argv)

View File

@ -1,25 +1,25 @@
import argparse
import sys
VALORI_AMMESSI = {"toto", "tata", "titi"}
vars = {"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.",
choices=vars,
help="Specify from 1 to 3 values from: toto, tata, titi.",
required=True
)
# Esegui parsing
# Execute 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)
print("Error: can be used **at max 3** values from 'toto', 'tata' and 'titi'.", file=sys.stderr)
sys.exit(1)
# Tutto OK
print("Valori accettati:", args.target)
print("You've written:", args.target)

View File

@ -2,9 +2,9 @@ import sys
import pyfiglet
if len(sys.argv) < 2:
print("Usa: python script.py 'testo da convertire'")
print("Usage: python script.py 'text to be converted'")
sys.exit(1)
text = " ".join(sys.argv[1:])
ascii_art = pyfiglet.figlet_format(text)
print(ascii_art)
f = pyfiglet.figlet_format(text)
print(f)