Skip to content

Commit

Permalink
[show]: Remove default commands; add missing docstrings (sonic-net#121)
Browse files Browse the repository at this point in the history
* [show]: Remove default groups; add missing docstrings

* Copy all bash completion files by glob
  • Loading branch information
jleveque authored Oct 5, 2017
1 parent 635735d commit 52dd13e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
from setuptools import setup

setup(
Expand Down Expand Up @@ -29,10 +30,7 @@
'scripts/teamshow',
],
data_files=[
('/etc/bash_completion.d', ['data/etc/bash_completion.d/config']),
('/etc/bash_completion.d', ['data/etc/bash_completion.d/sfputil']),
('/etc/bash_completion.d', ['data/etc/bash_completion.d/show']),
('/etc/bash_completion.d', ['data/etc/bash_completion.d/sonic_installer']),
('/etc/bash_completion.d', glob.glob('data/etc/bash_completion.d/*')),
],
entry_points={
'console_scripts': [
Expand Down
21 changes: 13 additions & 8 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def interfaces():
@click.argument('interfacename', required=False)
def alias(interfacename):
"""Show Interface Name/Alias Mapping"""

command = 'sonic-cfggen -d --var-json "PORT"'
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)

Expand Down Expand Up @@ -187,15 +188,16 @@ def summary(interfacename):
run_command(command)


@interfaces.group(cls=AliasedGroup, default_if_no_args=True)
@interfaces.group(cls=AliasedGroup, default_if_no_args=False)
def transceiver():
"""Show SFP Transceiver information"""
pass


@transceiver.command(default=True)
@transceiver.command()
@click.argument('interfacename', required=False)
def default(interfacename):
"""Show interface transceiver information"""
def basic(interfacename):
"""Show basic interface transceiver information"""

command = "sudo sfputil show eeprom"

Expand All @@ -205,9 +207,10 @@ def default(interfacename):
run_command(command)

@transceiver.command()
@click.argument('interfacename', required=True)
@click.argument('interfacename', required=False)
def details(interfacename):
"""Show interface transceiver details (Digital Optical Monitoring)"""

command = "sudo sfputil show eeprom --dom"

if interfacename is not None:
Expand All @@ -218,6 +221,8 @@ def details(interfacename):
@interfaces.command()
@click.argument('interfacename', required=False)
def description(interfacename):
"""Show interface status, protocol and description"""

if interfacename is not None:
command = "sudo vtysh -c 'show interface {}'".format(interfacename)
else:
Expand Down Expand Up @@ -514,13 +519,13 @@ def environment():
# 'processes' group ("show processes ...")
#

@cli.group(cls=AliasedGroup, default_if_no_args=True)
@cli.group(cls=AliasedGroup, default_if_no_args=False)
def processes():
"""Display process information"""
pass

@processes.command(default=True)
def default():
@processes.command()
def summary():
"""Show processes info"""
# Run top batch mode to prevent unexpected newline after each newline
run_command('ps -eo pid,ppid,cmd,%mem,%cpu ')
Expand Down

0 comments on commit 52dd13e

Please sign in to comment.