Skip to content

Commit 32f31d2

Browse files
committed
Add docs and toolbar entry
1 parent b39cf39 commit 32f31d2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ Inline Documentation
180180
The aws-shell will automatically pull up documentation as you type commands.
181181
It will show inline documentation for CLI options. There is also a separate
182182
documentation panel that will show documentation for the current command or
183-
option you are typing.
183+
option you are typing. Pressing F9 or clicking this panel will focus it
184+
allowing the use of your keybindings or scroll wheel to navigate the docs.
184185

185186
.. image:: https://cloud.githubusercontent.com/assets/368057/11823320/36ae9b04-a328-11e5-9661-81abfc0afe5a.png
186187

@@ -211,6 +212,7 @@ The aws-shell has a bottom toolbar that provides several options:
211212
* ``F3`` toggles between VI and Emacs key bindings
212213
* ``F4`` toggles between single and multi column auto completions
213214
* ``F5`` shows and hides the help documentation pane
215+
* ``F9`` toggles focus between the cli and documentation pane
214216
* ``F10`` or ``Ctrl-D`` exits the aws-shell
215217

216218
As you toggle options in the toolbar, your preferences are persisted

awsshell/toolbar.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def _create_toolbar_handler(self, get_match_fuzzy, get_enable_vi_bindings,
5454
assert callable(get_show_completion_columns)
5555
assert callable(get_show_help)
5656

57-
def get_toolbar_items(_):
57+
def get_toolbar_items(cli):
5858
"""Return the toolbar items.
5959
60-
:type _: :class:`prompt_toolkit.Cli`
61-
:param _: (Unused)
60+
:type cli: :class:`prompt_toolkit.Cli`
61+
:param cli: The command line interface from prompt_toolkit
6262
6363
:rtype: list
6464
:return: A list of (pygments.Token.Toolbar, str).
@@ -87,6 +87,10 @@ def get_toolbar_items(_):
8787
else:
8888
show_help_token = Token.Toolbar.Off
8989
show_help_cfg = 'OFF'
90+
if cli.current_buffer_name == 'DEFAULT_BUFFER':
91+
show_buffer_name = 'cli'
92+
else:
93+
show_buffer_name = 'doc'
9094
return [
9195
(match_fuzzy_token,
9296
' [F2] Fuzzy: {0} '.format(match_fuzzy_cfg)),
@@ -96,6 +100,8 @@ def get_toolbar_items(_):
96100
' [F4] {0} Column '.format(show_columns_cfg)),
97101
(show_help_token,
98102
' [F5] Help: {0} '.format(show_help_cfg)),
103+
(Token.Toolbar,
104+
' [F9] Focus: {0} '.format(show_buffer_name)),
99105
(Token.Toolbar,
100106
' [F10] Exit ')
101107
]

tests/unit/test_toolbar.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ToolbarTest(unittest.TestCase):
2222

2323
def setUp(self):
2424
self.aws_shell = AWSShell(mock.Mock(), mock.Mock(), mock.Mock())
25+
self.cli = mock.Mock()
2526
self.toolbar = Toolbar(
2627
lambda: self.aws_shell.model_completer.match_fuzzy,
2728
lambda: self.aws_shell.enable_vi_bindings,
@@ -38,18 +39,21 @@ def test_toolbar_on(self):
3839
(Token.Toolbar.On, ' [F3] Keys: Vi '),
3940
(Token.Toolbar.On, ' [F4] Multi Column '),
4041
(Token.Toolbar.On, ' [F5] Help: ON '),
42+
(Token.Toolbar, ' [F9] Focus: doc '),
4143
(Token.Toolbar, ' [F10] Exit ')]
42-
assert expected == self.toolbar.handler(None)
44+
assert expected == self.toolbar.handler(self.cli)
4345

4446
def test_toolbar_off(self):
4547
self.aws_shell.model_completer.match_fuzzy = False
4648
self.aws_shell.enable_vi_bindings = False
4749
self.aws_shell.show_completion_columns = False
4850
self.aws_shell.show_help = False
51+
self.cli.current_buffer_name = 'DEFAULT_BUFFER'
4952
expected = [
5053
(Token.Toolbar.Off, ' [F2] Fuzzy: OFF '),
5154
(Token.Toolbar.On, ' [F3] Keys: Emacs '),
5255
(Token.Toolbar.On, ' [F4] Single Column '),
5356
(Token.Toolbar.Off, ' [F5] Help: OFF '),
57+
(Token.Toolbar, ' [F9] Focus: cli '),
5458
(Token.Toolbar, ' [F10] Exit ')]
55-
assert expected == self.toolbar.handler(None)
59+
assert expected == self.toolbar.handler(self.cli)

0 commit comments

Comments
 (0)