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

Support rich markup in version strings #187

Closed
glenfletcher opened this issue Jun 25, 2024 · 2 comments
Closed

Support rich markup in version strings #187

glenfletcher opened this issue Jun 25, 2024 · 2 comments

Comments

@glenfletcher
Copy link

While rich markup is supported by help messages, it is not used when printing the version instead, it's just a straight call to print

cyclopts/cyclopts/core.py

Lines 385 to 387 in 2fcef8f

def version_print(self) -> None:
"""Print the application version."""
print(self.version() if callable(self.version) else self.version)

I was able to work around this using the following based on help_print to override version_print:

class App(cyclopts.App):
    def version_print(self) -> None:
        """Print the application version."""
        console = self._resolve_console(None, None)
        console.print(self.version() if callable(self.version) else self.version)

from help_print, I just used the defaults for parameters tokens and console from help_print's singuature:

cyclopts/cyclopts/core.py

Lines 849 to 856 in 2fcef8f

console = self._resolve_console(tokens, console)
# Print the:
# my-app command COMMAND [ARGS] [OPTIONS]
if executing_app.usage is None:
console.print(format_usage(self, command_chain))
elif executing_app.usage: # i.e. skip empty-string.
console.print(executing_app.usage + "\n")

@BrianPugh
Copy link
Owner

thanks for the report! I'll open up a PR integrating these changes.

@BrianPugh
Copy link
Owner

resolved in #188

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

No branches or pull requests

2 participants