Parseado de argumentos creado
This commit is contained in:
22
status.py
Normal file
22
status.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
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:
|
||||||
|
# Parte web, comprobar que Código devuelve
|
||||||
|
else:
|
||||||
|
# Parte host, hará ping
|
||||||
Reference in New Issue
Block a user