Skip to content

Commit a1d255d

Browse files
committed
PATCH: additions to the cli
1 parent 78373c3 commit a1d255d

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

veracode/application.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ def __new__(self, name=None, sandbox=None, build=None):
2424
return NewApplication()
2525

2626
@classmethod
27-
def list(self, name_only=True):
27+
def list(self, id=False):
2828
""" Returns a list of applications for the current account
2929
3030
>>> apps = Application.list()
3131
>>> isinstance(apps, list)
3232
True
3333
"""
3434
apps = SDK.upload.GetAppList()
35-
if name_only:
36-
return [app.app_name for app in apps.app]
37-
return [ExistingApplication(app) for app in apps.app]
35+
if id:
36+
return [(app.app_id, app.app_name) for app in apps.app]
37+
return [app.app_name for app in apps.app]
3838

3939

4040
class NewApplication(object):
@@ -48,6 +48,7 @@ class NewApplication(object):
4848
True
4949
"""
5050
def __init__(self):
51+
# TODO: Properties class!
5152
self.id = None
5253
self.name = None
5354
self.vendor_id = None

veracode/cli/app/commands.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
import sys
33
from veracode.application import Application
44
from veracode.sandbox import Sandbox
5+
from tabulate import tabulate
56

67
@click.group()
78
def app():
89
pass
910

1011

1112
@app.command()
12-
def list():
13-
for app in Application.list():
14-
click.echo(app)
13+
@click.option('--format', '-f',
14+
help='Show app id and app name.')
15+
def list(format='simple'):
16+
headers = ['App ID', 'App Name']
17+
click.echo(tabulate(Application.list(id=True), headers=headers, tablefmt=format))
1518

1619

1720
@app.command()

veracode/cli/cli.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import click
2-
from app import commands as app
3-
from sandbox import commands as sandbox
4-
from user import commands as user
5-
from report import commands as report
2+
from .app import commands as app
3+
from .sandbox import commands as sandbox
4+
from .user import commands as user
5+
from .report import commands as report
6+
from veracode.log import veracode_logger
7+
logger = veracode_logger('veracode')
68

79
@click.group()
810
def main():

0 commit comments

Comments
 (0)