Skip to content

Commit

Permalink
help epilog with env var for api token
Browse files Browse the repository at this point in the history
  • Loading branch information
bortok committed Mar 15, 2024
1 parent dbc5553 commit 73d3e6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
15 changes: 9 additions & 6 deletions src/nrx/nrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +46,6 @@
import networkx as nx
import jinja2
import yaml
import textwrap

# Single source version
from nrx.__about__ import __version__
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 73d3e6e

Please sign in to comment.