-
Notifications
You must be signed in to change notification settings - Fork 116
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
cmd2 3.0.0 Discussion #1351
Comments
I think replacing most of cmd2's custom text formatting code with a combination of rich and rich-argparse is a fantastic idea. It will reduce the amount of custom code that we need to maintain for I'm intrigued by the idea of making async alerts and prompt changes event driven, but I'd want to understand more about the architecture for how this would work and how it may interact or interfere with other event loops. For this sort of thing, I think we should consider integrating with Textual as this provides a path to true terminal-based UIs. |
I think I understand what @kmvanbrunt is getting at about alerts. As I recall, right now it's the caller's responsibility to figure out what state the prompt is in and either immediately print an alert or come up with a mechanism to queue up the alert for later display. Rearchitecting so that we consume the alert and determine in cmd2 when/how to display the alert. In the most basic case, if the terminal is busy executing a command, then the alert gets queued. If the terminal is at the prompt then we do our prompt redraw thing. This opens the door for more advanced alerting methods that could take advantage of something like textual to have a dedicated GUI-like way of displaying alerts. I agree with moving the plugins back into cmd2 proper and integrate it with unit tests. It would make sense to expand our unit tests to handle cases with different combinations of commandsets / plugins loaded. The build system update will go a long way towards helping that. Definitely agree with trying to move more commands into pre-canned CommandSets. Definitely agree on rich. At this point it's quite mature. |
I like the idea of migrating to rich and rich-argparse for text output, it's mature and widely used. I'm supportive of the other changes listed above too (async improvements, removing macros, etc). Here's a couple other suggestions that are much bigger features which I'm happy to work on if there is enough enthusiasm for them.
|
I think, going back to @kmvanbrunt's point on moving commands into CommandSets, we can move settables into a CommandSet. This opens the door for these types of behavior to be modular and swappable so if there's a fundamentally different approach to managing settables it's just a matter of swapping which implementation you want to use. Agreed on the output functions. Over the course of a couple years I've been generalizing the output functions a bit. If we can focus a bit on that as well as change all of our internal code to use them, then that opens the door for mixins to override those for specific behaviors. Including possibly making it easier to embed inside of some sort of console UI (that could also be built with rich). |
@kotfu I like both of your ideas. I'm almost done integrating These are the most obvious areas to update:
Something like this for with console.capture() as capture:
console.print(tab_completion_output)
readline.rl.mode.console.write(capture.get()) I prefer doing 2 and possibly 3 if that's OK with everyone. @kotfu Since you've already done item 1 in |
I have one more idea for There is a known race condition between a
Therefore, I propose switching from
Switching to What are everyone's thoughts on this? |
The idea of basing I see benefits including:
However I do see this as likely a rather large and probably backwards incompatible breaking change. I think we might want to consider releasing some features in stages in minor releases prior to this. For example, the I also think if we do go the |
I've started converting |
#1377 Makes use of type hinting generics added to collections so we no longer need to import things like |
Now that
cmd2 2.5.0
is out, I'd like to start thinking aboutcmd2 3.0.0
. So here are a few features I'd like to see based on feedback we've received over the years.Full
rich
andrich-argparse
integration.I wrote the table and related formatting code in early 2020 to solve a problem that all existing table creators at the time had. None of them preserved text styles across multiple lines of a table cell. That was also right around the time
rich
was developing their table functionality so I wasn't aware of their library. In the years since,rich
has become the de facto library for formatting text in the terminal and it's widely used and well supported. So I think it's safe at this point to offload all of our text formatting torich
. This approach was also discussed in Regarding KISS and direction of the project #1251 .I have been testing our stuff with
rich-argparse
and I'm finding the switch very easy.Make async alerts and prompt changes event driven.
self.terminal_lock
to asynchronously print an alert. Incmd2 3.0
they will call a function likeadd_alert()
which adds to a queue andcmd2
will handle printing alerts when the prompt is on screen. Async prompt updates will provide a similar method.Consider moving some built-in commands to
CommandSets
or mixin classes.Remove macros.
self._input_line_to_statement()
. We could just callself._complete_statement()
directly.Modernize build system to be based on pyproject.toml #1334
ext_test
plugin might help here as well. It currently has its own build system and is required to run our unit tests. Can it become a part of the maincmd2
code or at least not be needed to run our unit tests?The text was updated successfully, but these errors were encountered: