Python readline Auto-Complete
<p>I want to implement auto-complete in Command Line Interface for the following : </p>

<pre><code>Food : 
  Fruits:
    Apples
    Oranges
  Vegetables:
    Carrot
    Beetroot
  Snacks:
    Chocolate
</code></pre>

<p>The output for the <code>&lt;TAB&gt;</code> would be : 
food<br>
and so on...</p>

<p>Commands would be like :
<code>Food Fruits Apples</code>
or <code>Food Snacks Chocolate</code></p>

<p>Came across this <a href="https://pymotw.com/2/readline/" rel="nofollow">https://pymotw.com/2/readline/</a> while googling. But I don't understand how begin/end works. And how it will change for further nesting.</p>

<p>Any sort of help is appreciated. (Writing code in python. Prefer to use readline library)</p>

<p>If you use a library like <a href="http://click.pocoo.org" rel="nofollow">click</a> for making your CLI you will get this mostly for free <a href="http://click.pocoo.org/5/bashcomplete/" rel="nofollow">http://click.pocoo.org/5/bashcomplete/</a></p>

python readline