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

Utility to allow a format option for commands. #342

Open
lengau opened this issue May 9, 2024 · 1 comment
Open

Utility to allow a format option for commands. #342

lengau opened this issue May 9, 2024 · 1 comment
Labels
Enhancement New feature or request

Comments

@lengau
Copy link
Contributor

lengau commented May 9, 2024

What needs to get done

Add utilities of some form to make it easy for commands to add a unified format option for various tabular command outputs.

Ideally a command's fill_parser method would be able to do something like:

utils.add_format_argument(parser)

and then we'd have a related function that actually emits the formatted message, something like:

def emit_formatted_output(format: FormatValue, headers: Sequence[str], data) -> None:
    ...

Here the data object would need to be something that can (at minimum) be used by tabulate and be serialised into JSON. With those two formats, we'd likely get the ability to do other formats (e.g. YAML, toml) if we decide to add that in the future.

Why it needs to get done

This got added to the names command in snapcraft recently: canonical/snapcraft#4778
Charmcraft has a partial implementation, but still relies on the command itself being aware of each format.

@lengau lengau added the Enhancement New feature or request label May 9, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2908.

This message was autogenerated

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

No branches or pull requests

1 participant