-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add --format
option to list
command.
#572
Conversation
This flag controls how the output should be formatted. It accepts 3 possible values: - `human`, the default value, uses the current output; - `freeze`, prints the installed packages using a format similar to `pip freeze` (`name==version`). - `json`: prints the complete details of the installed package in JSON
Thanks for the PR. I'm currently really busy with other pipx-related activities, so if it takes a few days for me or somebody else to look at this, please be patient, we'll get to it. 🙂 |
Thanks for the PR! It's nicer to have contributed code than contributed wishes 😄 Some questions: Since I'm not one who's been looking for this functionality, could you help me understand what the use case for this would be? How would this help a pipx user? Could you give some example outputs of the For the |
Thanks for getting back to this. The main use case of the structured format is automation. My main use case is rebuilding by development environment. Being able to easily export a list of packages installed with pipx helps reduce the effort required to keep the solution up to date. For the I attached the output
|
Ok, in that case, I think the "freeze" format leaves out some information, such as:
Adding some or all of those back in would stop it from looking like output from The question is if the "freeze" format is needed at all, given the absolutely complete "json" format. I suppose "freeze" could be useful for very primitive scripts, possibly shell scripts. Another interesting option I just thought of would be a "script" output, which would just be the shell commands, e.g.:
etc. The whole point of having |
And sorry, above when I asked about |
The question I haven’t seen asked throughout the discussion (including here and linked issues) is how the output is expected to be used. If it is supposed to be fed back into pipx (either directly or indirectly), maybe the best solution is to provide a pair of |
I literally just asked 3 comments ago "What's the use case?" 😆 He answered " My main use case is rebuilding my development environment." To which I suggested |
But nobody went that route, and I assume people have reasons to prefer |
That actually seems to be a better, more thought through option. Do you want to close this PR and make an issue to discuss this further? |
Sure, especially if that's ok with you. Again, thanks so much for actually taking the time to contribute code, we always appreciate it. In this case it just seems we need to more thinking on exactly how the functionality should work. |
This flag controls how the output should be formatted. It accepts 3
possible values:
human
, the default value, uses the current output;freeze
, prints the installed packages using a format similar topip freeze
(name==version
).json
: prints the complete details of the installed package in JSONdocs/changelog.md
Summary of changes
src/pipx/main.py
to add the--format
optionsrc/pipx/commands/list_packages.py
to implement the new formatsdocs/examples.md
to add an example of the new functionalityTest plan
Ensure that the following commands produce the expected output:
The following command should produce the same output as the current version of pipx
The
--format freeze
option should list only installed packages and versions:$ pipx list --format freeze
The
--format json
should list the complete details of the installed packages.