Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default is ignored on lists #17

Closed
martenjacobs opened this issue Oct 2, 2018 · 5 comments
Closed

Default is ignored on lists #17

martenjacobs opened this issue Oct 2, 2018 · 5 comments

Comments

@martenjacobs
Copy link

martenjacobs commented Oct 2, 2018

It seems that the default-key is ignored on list-type questions

Consider the following code:

from PyInquirer import prompt, print_json

answer = prompt({
        'type': 'list',
        'name': "test-question",
        'message': "Select item",
        'default': 2,
        'choices': [
            {   "name"  : "Item 1",
                "value" : "item1"   },
            {   "name"  : "Item 2",
                "value" : "item2"   },
            {   "name"  : "Item 3",
                "value" : "item3"   },
            {   "name"  : "Item 4",
                "value" : "item4"   },
        ]
    })

print_json(answer)

Expected result:

Item 3 is initially selected in the prompt

Actual result:

Item 1 is initially selected in the prompt

Environment:

OS: macOS 10.14 Mojave

$ python3 --version
Python 3.6.1
$ python3 -m pip show PyInquirer
Name: PyInquirer
Version: 1.0.2
Summary: A Python module for collection of common interactive command line user interfaces, based on Inquirer.js
Home-page: https://github.com/CITGuru/PyInquirer/
Author: Oyetoke Toby
Author-email: oyetoketoby80@gmail.com
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires: prompt-toolkit, Pygments, regex
Required-by:
@CITGuru
Copy link
Owner

CITGuru commented Oct 3, 2018

I'll take a closer look at this.

@CITGuru
Copy link
Owner

CITGuru commented Nov 12, 2018

Yes its actually ignored cos, you have to choose one from the list.

@CITGuru CITGuru closed this as completed Nov 12, 2018
@martenjacobs
Copy link
Author

From documentation it appears you should be able to define the initially selected list item. Either the documentation should be clarified or this feature should be implemented.

@ajdavis
Copy link

ajdavis commented Feb 22, 2020

I believe this issue should be reopened, it's still present in version 1.0.3 on PyPI and on master.

@ewels
Copy link

ewels commented Jun 26, 2020

Looks like this has now been fixed in #68 - we just need a release (#90)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants