canonical / craft-cli

https://canonical-craft-cli.readthedocs-hosted.com/en/latest/
GNU Lesser General Public License v3.0
9 stars 15 forks source link

Include humanize_list function as a utility #183

Open lengau opened 11 months ago

lengau commented 11 months ago

What needs to get done

  1. Copy this function and its relevant tests to craft-cli: https://github.com/canonical/craft-parts/blob/main/craft_parts/utils/formatting_utils.py
  2. Make a craft-cli release
  3. Update craft apps to reference this function instead of their own instances of it.
  4. Make comments both here and in the craft-parts implementation that the function exists in the other location so we can copy bug fixes if needed. (No functional changes in craft-parts)

Why it needs to get done

Reduced copy/pasting of code for improved maintainability

tigarmo commented 11 months ago

Are we sure that this lib is the right place for this function? I can see that in the majority of cases the list if being humanized to be emitted/logged, but a side-effect of this is that the libs (like craft-parts and -providers) would start having craft-cli as a dependency. Which isn't awful necessarily , but is a consequence we need to consider.

...

At the same time, I'm not a huge fan of a grab-bag "craft-util" lib because it feels a bit chaotic, so I don't have any better suggestions, heh.

tigarmo commented 11 months ago

Maybe we could get this landed and use python-humanize?

lengau commented 11 months ago

@tigarmo I was just typing the same thing