From 7e6ebb04f8fc13af50677a7ce6a375ff00a1e0cb Mon Sep 17 00:00:00 2001 From: Alex Bortok <431965+bortok@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:43:52 -0700 Subject: [PATCH 1/4] added online documentation link to help --- src/nrx/nrx.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nrx/nrx.py b/src/nrx/nrx.py index b9c8c62..627c590 100755 --- a/src/nrx/nrx.py +++ b/src/nrx/nrx.py @@ -983,7 +983,13 @@ def arg_input_check(s): def parse_args(): """CLI arguments parser""" - args_parser = argparse.ArgumentParser(prog='nrx', description="nrx - network topology exporter by netreplica") + from argparse import RawDescriptionHelpFormatter + args_parser = argparse.ArgumentParser(prog='nrx', formatter_class=RawDescriptionHelpFormatter, + description=""" + nrx - network topology exporter by netreplica + + online documentation: https://github.com/netreplica/nrx/blob/main/README.md + """) sites_group = args_parser.add_mutually_exclusive_group() From dbc55536019da64204920f63bcda50f7173601b1 Mon Sep 17 00:00:00 2001 From: Alex Bortok <431965+bortok@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:47:39 -0700 Subject: [PATCH 2/4] ident help desc in code --- src/nrx/nrx.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/nrx/nrx.py b/src/nrx/nrx.py index 627c590..76eec84 100755 --- a/src/nrx/nrx.py +++ b/src/nrx/nrx.py @@ -43,6 +43,7 @@ import networkx as nx import jinja2 import yaml +import textwrap # Single source version from nrx.__about__ import __version__ @@ -984,12 +985,13 @@ def arg_input_check(s): def parse_args(): """CLI arguments parser""" from argparse import RawDescriptionHelpFormatter - args_parser = argparse.ArgumentParser(prog='nrx', formatter_class=RawDescriptionHelpFormatter, - description=""" - nrx - network topology exporter by netreplica + args_parser = argparse.ArgumentParser(prog='nrx', + formatter_class=RawDescriptionHelpFormatter, + description=textwrap.dedent(""" + nrx - network topology exporter by netreplica - online documentation: https://github.com/netreplica/nrx/blob/main/README.md - """) + online documentation: https://github.com/netreplica/nrx/blob/main/README.md + """)) sites_group = args_parser.add_mutually_exclusive_group() From 73d3e6e0dec47d4d36e87c156c4a250dac8ce4dd Mon Sep 17 00:00:00 2001 From: Alex Bortok <431965+bortok@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:56:27 -0700 Subject: [PATCH 3/4] help epilog with env var for api token --- README.md | 5 +++++ src/nrx/nrx.py | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 303a250..e6a3304 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,8 @@ usage: nrx [-h] [-v] [-d] [-I [VERSION]] [-c CONFIG] [-i INPUT] [-o OUTPUT] [-a nrx - network topology exporter by netreplica +online documentation: https://github.com/netreplica/nrx/blob/main/README.md + optional arguments: -h, --help show this help message and exit -v, --version show version number and exit @@ -162,6 +164,9 @@ optional arguments: -T, --templates TEMPLATES directory with template files, will be prepended to TEMPLATES_PATH list in the configuration file -M, --map MAP file with platform mappings to node parameters (default: platform_map.yaml in templates folder) -D, --dir DIR save files into directory DIR (topology name is used by default). nested relative and absolute paths are OK + +To pass authentication token, use configuration file or environment variable: +export NB_API_TOKEN='replace_with_valid_API_token' ``` Note: for security reasons, there is no argument to pass an API token. Use either an environmental variable or a configuration file. diff --git a/src/nrx/nrx.py b/src/nrx/nrx.py index 76eec84..caf886b 100755 --- a/src/nrx/nrx.py +++ b/src/nrx/nrx.py @@ -26,14 +26,17 @@ It can also read the topology graph previously saved as a CYJS file to convert it into the one of supported network emulation formats. """ - +# Standard library imports import os import sys import argparse +from argparse import RawDescriptionHelpFormatter import json import math import ast +import textwrap import zipfile +# Third-party library imports import toml import pynetbox import requests @@ -43,7 +46,6 @@ import networkx as nx import jinja2 import yaml -import textwrap # Single source version from nrx.__about__ import __version__ @@ -984,14 +986,15 @@ def arg_input_check(s): def parse_args(): """CLI arguments parser""" - from argparse import RawDescriptionHelpFormatter args_parser = argparse.ArgumentParser(prog='nrx', formatter_class=RawDescriptionHelpFormatter, description=textwrap.dedent(""" - nrx - network topology exporter by netreplica + nrx - network topology exporter by netreplica - online documentation: https://github.com/netreplica/nrx/blob/main/README.md - """)) + online documentation: https://github.com/netreplica/nrx/blob/main/README.md"""), + epilog=textwrap.dedent(""" + To pass authentication token, use configuration file or environment variable: + export NB_API_TOKEN='replace_with_valid_API_token'""")) sites_group = args_parser.add_mutually_exclusive_group() From 7deafe943614f75b6b8d01109f5b699e06252eca Mon Sep 17 00:00:00 2001 From: Alex Bortok <431965+bortok@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:56:52 -0700 Subject: [PATCH 4/4] bumped ver --- src/nrx/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nrx/__about__.py b/src/nrx/__about__.py index 03a523b..bb416cc 100644 --- a/src/nrx/__about__.py +++ b/src/nrx/__about__.py @@ -19,4 +19,4 @@ """ Metadata for the nrx package """ -__version__ = "0.5.0rc1" +__version__ = "0.5.0rc2"