feat: Semaine 9
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import argparse
|
||||
import time
|
||||
|
||||
def timer_command(fonction):
|
||||
def internal_wrapper(args):
|
||||
if args.verbose:
|
||||
print("[DEBUG] Lancement de la commande...")
|
||||
start_time = time.perf_counter()
|
||||
result = fonction(args)
|
||||
print(f"[DEBUG] Terminé en {time.perf_counter() - start_time}")
|
||||
return result
|
||||
return fonction(args)
|
||||
return internal_wrapper
|
||||
|
||||
parser = argparse.ArgumentParser(description="Un scanneur")
|
||||
parser.add_argument("-n", "--numbers", nargs= "+", type= int, help="Nombres à additioner")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="Mode verbeux")
|
||||
|
||||
@timer_command
|
||||
def addition(args):
|
||||
return sum(args.numbers)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(addition(args))
|
||||
Reference in New Issue
Block a user