Skip to content

Commit

Permalink
Merge pull request #107 from netreplica/help-docs
Browse files Browse the repository at this point in the history
CLI help with links to documentation and env var for api token
  • Loading branch information
bortok authored Mar 15, 2024
2 parents ab584b0 + 7deafe9 commit a13822c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 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
2 changes: 1 addition & 1 deletion src/nrx/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"""
Metadata for the nrx package
"""
__version__ = "0.5.0rc1"
__version__ = "0.5.0rc2"
15 changes: 13 additions & 2 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 Down Expand Up @@ -983,7 +986,15 @@ def arg_input_check(s):

def parse_args():
"""CLI arguments parser"""
args_parser = argparse.ArgumentParser(prog='nrx', 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"""),
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 a13822c

Please sign in to comment.