Cannot set operation argument as list from CLI
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start by reproducing the listed server.user CLI commands and tracing the CLI operation-argument parsing. Verify that a list-valued groups argument reaches server.user as a list of strings rather than characters, while ordinary string arguments remain unchanged.
Written by the indexing model from the issue text.
Description
Describe the bug
The operation server.user accepts an argument groups which needs to be a list of strings.
There is no way to define a list when calling this operation from the CLI - it always ends up as list of single characters.
To Reproduce
This all does not work:
pyinfra INVENTORY.py server.user user=abc groups=[group1]
pyinfra INVENTORY.py server.user user=abc groups=["group1"]
pyinfra INVENTORY.py server.user user=abc 'groups=[group1]'
pyinfra INVENTORY.py server.user user=abc groups='["group1"]'
pyinfra INVENTORY.py server.user user=abc 'groups=["group1"]'
because the CLI does not interpret the arguments.
Expected behavior
It should be possible to set arguments which require lists.
Just changing kwargs[key] = value to e.g.
try:
kwargs[key] = ast.literal_eval(value)
except (SyntaxError, ValueError):
kwargs[key] = value
should be sufficient.
Meta
pyinfra v3.9.2
Other facts are not relevant.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 548
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 13
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyinfra-dev/pyinfra
-
new feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pyinfra-dev/pyinfra#1967 ·
-
facts new feature operations
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pyinfra-dev/pyinfra#1896 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
pyinfra-dev/pyinfra#1235 · 2 comments · 2 reactions ·
-
bug operations
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
pyinfra-dev/pyinfra#1219 · 2 comments · 2 reactions ·
-
operations spec
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pyinfra-dev/pyinfra#1207 · 2 comments ·
All issues in pyinfra-dev/pyinfra
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100