Skip to content

Commit 16e1086

Browse files
Merge pull request #842 from flavio-fernandes/first_example.merge
doc: improve first example of slcli
2 parents 172964c + 9da22ba commit 16e1086

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

docs/dev/cli.rst

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@ For the first example, we can create `slcli table-example` by creating the follo
1313

1414
::
1515

16+
"""A formatting table example."""
17+
from SoftLayer.CLI import environment
1618
from SoftLayer.CLI import formatting
1719

1820
import click
1921

2022

2123
@click.command()
22-
def cli():
24+
@environment.pass_env
25+
def cli(env):
2326
"""This returns an table that highlights how tables are output"""
2427
# create a table with two columns: col1, col2
25-
t = formatting.Table(['col1', 'col2'])
28+
table = formatting.Table(['col1', 'col2'])
2629

2730
# align the data facing each other
2831
# valid values are r, c, l for right, center, left
2932
# note, these are suggestions based on the format chosen by the user
30-
t.align['col1'] = 'r'
31-
t.align['col2'] = 'l'
33+
table.align['col1'] = 'r'
34+
table.align['col2'] = 'l'
3235

3336
# add rows
34-
t.add_row(['test', 'test'])
35-
t.add_row(['test2', 'test2'])
37+
table.add_row(['test', 'test'])
38+
table.add_row(['test2', 'test2'])
3639

37-
return t
40+
env.fout(table)
3841

3942
Then we need to register it so that `slcli table-example` will know to route to this new module. We do that by adding ALL_ROUTES in SoftLayer/CLI/routes.py to include the following:
4043

0 commit comments

Comments
 (0)