add -v --version command

This commit is contained in:
fluzzi 2022-04-05 20:04:18 -03:00
parent c83a2cd28f
commit 815c161544
5 changed files with 15 additions and 2 deletions

View File

@ -76,6 +76,7 @@ positional arguments:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-v, --version Show version
``` ```

View File

@ -29,6 +29,7 @@ Options:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-v, --version Show version
Commands: Commands:
profile Manage profiles profile Manage profiles
@ -123,10 +124,10 @@ mynodes.router1.run(["term len 0". "show run"], folder = "/home/user/logs")
from .core import node,nodes from .core import node,nodes
from .configfile import configfile from .configfile import configfile
from .connapp import connapp from .connapp import connapp
from ._version import __version__
from pkg_resources import get_distribution from pkg_resources import get_distribution
__all__ = ["node", "nodes", "configfile", "connapp"] __all__ = ["node", "nodes", "configfile", "connapp"]
__version__ = "2.0.3"
__author__ = "Federico Luzzi" __author__ = "Federico Luzzi"
__pdoc__ = { __pdoc__ = {
'core': False, 'core': False,

2
connpy/_version.py Normal file
View File

@ -0,0 +1,2 @@
__version__ = "2.0.3"

View File

@ -9,6 +9,7 @@ import argparse
import sys import sys
import inquirer import inquirer
from .core import node from .core import node
from ._version import __version__
#functions and classes #functions and classes
@ -45,6 +46,7 @@ class connapp:
nodecrud.add_argument("-e","--mod", "--edit", dest="action", action="store_const", help="Modify node[@subfolder][@folder]", const="mod", default="connect") nodecrud.add_argument("-e","--mod", "--edit", dest="action", action="store_const", help="Modify node[@subfolder][@folder]", const="mod", default="connect")
nodecrud.add_argument("-s","--show", dest="action", action="store_const", help="Show node[@subfolder][@folder]", const="show", default="connect") nodecrud.add_argument("-s","--show", dest="action", action="store_const", help="Show node[@subfolder][@folder]", const="show", default="connect")
nodecrud.add_argument("-d","--debug", dest="action", action="store_const", help="Display all conections steps", const="debug", default="connect") nodecrud.add_argument("-d","--debug", dest="action", action="store_const", help="Display all conections steps", const="debug", default="connect")
nodecrud.add_argument("-v","--version", dest="action", action="store_const", help="Show version", const="version", default="connect")
nodeparser.set_defaults(func=self._func_node) nodeparser.set_defaults(func=self._func_node)
#PROFILEPARSER #PROFILEPARSER
profileparser = subparsers.add_parser("profile", help="Manage profiles") profileparser = subparsers.add_parser("profile", help="Manage profiles")
@ -99,6 +101,8 @@ class connapp:
#Function called when connecting or managing nodes. #Function called when connecting or managing nodes.
if not self.case and args.data != None: if not self.case and args.data != None:
args.data = args.data.lower() args.data = args.data.lower()
if args.action == "version":
print(__version__)
if args.action == "connect" or args.action == "debug": if args.action == "connect" or args.action == "debug":
if args.data == None: if args.data == None:
matches = self.nodes matches = self.nodes

View File

@ -48,6 +48,7 @@ Options:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-v, --version Show version
Commands: Commands:
profile Manage profiles profile Manage profiles
@ -162,6 +163,7 @@ Options:
-e, --mod, --edit Modify node[@subfolder][@folder] -e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder] -s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps -d, --debug Display all conections steps
-v, --version Show version
Commands: Commands:
profile Manage profiles profile Manage profiles
@ -256,10 +258,10 @@ mynodes.router1.run(["term len 0". "show run"], folder = "/h
from .core import node,nodes from .core import node,nodes
from .configfile import configfile from .configfile import configfile
from .connapp import connapp from .connapp import connapp
from ._version import __version__
from pkg_resources import get_distribution from pkg_resources import get_distribution
__all__ = ["node", "nodes", "configfile", "connapp"] __all__ = ["node", "nodes", "configfile", "connapp"]
__version__ = "2.0.3"
__author__ = "Federico Luzzi" __author__ = "Federico Luzzi"
__pdoc__ = { __pdoc__ = {
'core': False, 'core': False,
@ -654,6 +656,7 @@ __pdoc__ = {
nodecrud.add_argument("-e","--mod", "--edit", dest="action", action="store_const", help="Modify node[@subfolder][@folder]", const="mod", default="connect") nodecrud.add_argument("-e","--mod", "--edit", dest="action", action="store_const", help="Modify node[@subfolder][@folder]", const="mod", default="connect")
nodecrud.add_argument("-s","--show", dest="action", action="store_const", help="Show node[@subfolder][@folder]", const="show", default="connect") nodecrud.add_argument("-s","--show", dest="action", action="store_const", help="Show node[@subfolder][@folder]", const="show", default="connect")
nodecrud.add_argument("-d","--debug", dest="action", action="store_const", help="Display all conections steps", const="debug", default="connect") nodecrud.add_argument("-d","--debug", dest="action", action="store_const", help="Display all conections steps", const="debug", default="connect")
nodecrud.add_argument("-v","--version", dest="action", action="store_const", help="Show version", const="version", default="connect")
nodeparser.set_defaults(func=self._func_node) nodeparser.set_defaults(func=self._func_node)
#PROFILEPARSER #PROFILEPARSER
profileparser = subparsers.add_parser("profile", help="Manage profiles") profileparser = subparsers.add_parser("profile", help="Manage profiles")
@ -708,6 +711,8 @@ __pdoc__ = {
#Function called when connecting or managing nodes. #Function called when connecting or managing nodes.
if not self.case and args.data != None: if not self.case and args.data != None:
args.data = args.data.lower() args.data = args.data.lower()
if args.action == "version":
print(__version__)
if args.action == "connect" or args.action == "debug": if args.action == "connect" or args.action == "debug":
if args.data == None: if args.data == None:
matches = self.nodes matches = self.nodes