Skip to content

Commit 21ad2e3

Browse files
committed
Just added some comments at the top of the example to try to give some context
1 parent 6fc6bee commit 21ad2e3

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/bash_completion.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
#!/usr/bin/env python3
22
# coding=utf-8
33
# PYTHON_ARGCOMPLETE_OK - This is required at the beginning of the file to enable argcomplete support
4-
"""A simple example demonstrating integration with argcomplete"""
4+
"""A simple example demonstrating integration with argcomplete.
5+
6+
This example demonstrates how to achieve automatic auto-completion of argparse arguments for a command-line utility
7+
(CLU) in the Bash shell.
8+
9+
Realistically it will probably only work on Linux and then only in a Bash shell. With some effort you can probably get
10+
it to work on macOS or Windows Subsystem for Linux (WSL); but then again, specifically within a Bash shell. This
11+
automatic Bash completion integration with the argcomplete module is included within cmd2 in order to assist developers
12+
with providing a the best possible out-of-the-box experience with their cmd2 applications, which in many cases will
13+
accept argparse arguments on the command-line when executed. But from an architectural point of view, the
14+
"argcomplete_bridge" functionality within cmd2 doesn't really depend on the rest of cmd2 and could be used in your own
15+
CLU which doesn't use cmd2.
16+
17+
WARNING: For this example to work correctly you need the argcomplete module installed and activated:
18+
pip install argcomplete
19+
activate-global-python-argcomplete
20+
Please see https://github.com/kislyuk/argcomplete for more information on argcomplete.
21+
"""
522
import argparse
623

724
optional_strs = ['Apple', 'Banana', 'Cranberry', 'Durian', 'Elderberry']

0 commit comments

Comments
 (0)