KEMBAR78
Print Default Values of String-to-String in Sorted Order by vaguecoder · Pull Request #365 · spf13/pflag · GitHub
Skip to content

Conversation

@vaguecoder
Copy link

Motivation

Issue 362 reported by @SOF3

Changes

Sort keys before stringifying string-to-string flag values.

Summary

String-to-string default values in usage would print in sorted order of keys.
Eg. --foo stringToString usage (default [a=b,c=d])
In the example as per #362, now, the order will be always default [a=b,c=d]

Related Issues

Closes #362

@SOF3
Copy link

SOF3 commented Nov 20, 2022

what about string to other types like integers?

@vaguecoder
Copy link
Author

what about string to other types like integers?

Yes, there are another 2 places. Let this PR be a PoC. We can have set of issue-PR to address those.

  1. String to int
  2. String to int64

Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
@tomasaschan
Copy link
Collaborator

I took the liberty of rebasing this onto latest master to ensure the test suite could run and verify the changes. Seems fine, so I'll merge it. Thanks for your contribution!

@tomasaschan tomasaschan merged commit 094909d into spf13:master Aug 29, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

StringToString usage output is unstable

4 participants