Add CLI options for git URL

help text to CLI options
This commit is contained in:
Mark Tinberg 2020-11-12 13:20:21 -06:00
parent 1f31c11eda
commit 54907aaffb

View File

@ -3,13 +3,12 @@ from collections import Counter
import yaml, pynetbox, glob, argparse, os, settings
parser = argparse.ArgumentParser(description='Import Netbox Device Types')
parser.add_argument('--vendor', nargs='+')
parser.add_argument('--vendor', nargs='+', help="List of vendors to import eg. apc cisco")
parser.add_argument('--url','--git', default='https://github.com/netbox-community/devicetype-library.git', help="Git URL with valid Device Type YAML files")
args = parser.parse_args()
cwd = os.getcwd()
counter = Counter(added=0,updated=0,manufacturer=0)
url = 'https://github.com/netbox-community/devicetype-library.git'
nbUrl = settings.NETBOX_URL
nbToken = settings.NETBOX_TOKEN
@ -249,10 +248,10 @@ try:
update_package('./repo')
print(msg)
else:
repo = Repo.clone_from(url, os.path.join(cwd, 'repo'))
repo = Repo.clone_from(args.url, os.path.join(cwd, 'repo'))
print("Package Installed")
except exc.GitCommandError as error:
print("Couldn't clone {} ({})".format(url, error))
print("Couldn't clone {} ({})".format(args.url, error))
nb = pynetbox.api(nbUrl, token=nbToken)