Open DrewNaylor opened 3 years ago
Nah, we can just switch over to PowerShell for now since it doesn't seem to remove items like CMD does.
As stated in https://github.com/DrewNaylor/guinget/issues/78#issuecomment-737906327, neither CMD nor PowerShell have infinite scrollback buffers, so I'm going to just read the output into a textbox, or if I can manage it, a ListBox or even DataGridView.
This textbox should be in a form with a Close
button in the bottom-right corner next to a Save to text file
button. The textbox may need both horizontal and vertical scrolling and the window will definitely need to be resizable. Probably would be a good idea to reuse this form for stuff like the upgrades by doing what I do with the download progress form. Could look nice to have an indeterminate progress bar below a "Loading packages, please wait..." label that shows up while loading the lists of installed packages and upgrades. Probably should run winget source update
beforehand so the progress bar doesn't mess with the textbox. It's possible that updating the sources will have issues, so redirecting standard error will be important.
Just to make things simple, there should be a way to display just a textbox and a way to show a tabcontrol that has both a textbox and a consolecontrol (as mentioned in the first post). The one with the consolecontrol can be used to show the output from winget source update
instead of just putting it in a textbox.
Actually, maybe the ConEmu control could be used instead of ConsoleControl: https://www.nuget.org/packages/ConEmu.Control.WinForms/
Doing the fancy two-tab thing was too much work that I don't really know how to do right now, so maybe I can just have a reusable window with ConEmu embedded that runs specific commands based on which one is clicked in the menubar. The Save to file
button can just run the command a second time and pipe the output to a file of the user's choosing.
I'll also have to copy ConEmu's EXE files to somewhere in the bin
directory, possibly in \bin\tools\conemu\
. May as well eventually bundle 7-Zip in there while I'm at it, so that can be \bin\tools\7zip\
. The installer should be changed to allow the user to not install these components if they don't want them to take up more space or they already have them installed.
Allowing path configuration for these tools would be a good idea as would allowing people to use CMD instead of ConEmu. Maybe the way that can work is there's a minimal form in "CMD mode" that has the buttons for saving the list of installed packages and re-running the list command, but no ConEmu control. If ConEmu can't be found, it'll fall back to "CMD Mode" automatically. Some people may not like the minimal form, so allowing people to not show it would be a good idea. Probably just do something like, %guingetdir%\tools\conemu\conemu.exe
by default in the Settings and just expand %guingetdir%
to the directory for guinget.exe
.
After saving the list, there should be a label that says, "Saving package list..." that changes to "Saved." after it's finished saving it if it completes successfully. Should check the exit code to see different situations where the file is read-only or winget's not installed, and stuff.
If I use a textbox or another similar control without support for ANSI sequences, I'll have to replace the spinner thing.
Did a quick test with listing in a textbox, and it just looks bad. Probably would have to use monospace fonts to make it look ok sometimes, but there's a lot that just ends suddenly. None of this is mentioning the progress bar text when the command is run that would have to be removed with a replace thing. Might have to do something like watch the output and put it into a nice list right after the progress bar is full, but that doesn't help with the part where the column just ends.
Would have to make sure to update the sources beforehand so it doesn't look horrible. Maybe if PowerShell doesn't trim off the output past a certain point, the commands could be switched to use it instead. Would prefer to stick with CMD since it's a lot faster to start, though. Hopefully that ConsoleControl would work and display all the packages that are installed.