22 lines
683 B
Python
22 lines
683 B
Python
import argparse
|
|
|
|
def parseArguments():
|
|
# Crear un objeto ArgumentParser
|
|
parser = argparse.ArgumentParser(description='Ejemplo de script con flags')
|
|
|
|
# Agregar los argumentos con sus respectivos flags
|
|
parser.add_argument('-w', '--web', action='store', dest='web', help='Indicar una web')
|
|
parser.add_argument('-h', '--host', action='store', dest='host', help='Indicar un host')
|
|
|
|
# Parsear los argumentos de la línea de comandos
|
|
args = parser.parse_args()
|
|
|
|
return args
|
|
|
|
|
|
if __name__ == '__main__':
|
|
args = parseArguments()
|
|
if args.web:
|
|
print()# Parte web, comprobar que Código devuelve
|
|
else:
|
|
print()# Parte host, hará ping |