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

ProgressBar does not expose current #69

Open
MihailsKuzmins opened this issue Dec 14, 2020 · 8 comments
Open

ProgressBar does not expose current #69

MihailsKuzmins opened this issue Dec 14, 2020 · 8 comments

Comments

@MihailsKuzmins
Copy link

A class ProgressBar creates a ProgressBarTwoLine or ProgressBarSlim under the hood. Both of them have a field _current, however, for the time being only ProgressBarSlim exposes the current value.
Could it be possible that the class ProgressBar exposes it as well? This property could be added a get-only property to IProgressBar. Does not look like a lot-to-do and it would be a handy property :)

@goblinfactory
Copy link
Owner

Easy enough to add to next relase.
I'm sorry I can't bring out a quick fix for this now, ... will be working quite extensively on konsole V7 and will add it for sure when i do that.

I might update the standalone ProgressBar library first, that is a much smaller project : https://github.com/goblinfactory/progress-bar

watch that lib as well, depending what features you need. if you only need progress bar features, then that lib is much simpler.

@MihailsKuzmins
Copy link
Author

@goblinfactory if you do not mind I could create a PR for it. Like I said it should not take too much time to do it

@goblinfactory
Copy link
Owner

goblinfactory commented Dec 15, 2020

Nice! If you submit a PR for https://github.com/goblinfactory/progress-bar I'll review it tomorrow night and create a new nuget.

That project is quite casual and simple.

Unfortunately konsole wont be able to take PR's until I get a bunch of stuff done according to dotnet foundation guidelines, contributor agreements etc and I won't have time to look at that until this weekend when I'm on leave.

@goblinfactory
Copy link
Owner

Hi @MihailsKuzmins I've merged your PR in https://github.com/goblinfactory/progress-bar
and have published a new package to nuget, official progress bar 1.0.0 woot!
https://www.nuget.org/packages/Goblinfactory.ProgressBar
ping me if there's anything I need to tweak.
cheers,
Alan

@goblinfactory
Copy link
Owner

(give Nuget a few minutes to validate the package)

@goblinfactory
Copy link
Owner

goblinfactory commented Feb 8, 2021

@MihailsKuzmins I've created an alpha release for konsole with some progress bar improvements, including exposing .Current.
The package is available for preview. 6.3.0-alpha please let me know if you find any bugs or have any issues and I'll look into that immediately.

https://www.nuget.org/packages/Goblinfactory.Konsole/6.3.0-alpha

I've also added two new progress bar objects,

  • ProgressCharBar
  • CharBar

ProgressCharBar is a (no text) progressbar that automatically fills the width of the parent window to 100%.
CharBar is similar to ProgressCharBar but has a fixed width, and x and y co-ordinates. It's intended to be used for small status indicators of various usage.

Here is an example of CharBar

        [Test]
        public void show_percentage_correctly_25_perecent()
        {
            //begin-snippet: ProgressCharBar
            // 'OpenBox' opens to fill the entire parent window.
            // this test runs inside a mock console 22 chars wide, by 3 lines tall.
            // hence the 22x3 box shown in the buffer below.
            // -------------------------------------------
            var box = Window.OpenBox("test progress");
            
            // default color is green, default char is #
            var pb = new ProgressCharBar(box, max: 4); 
            pb.Refresh(1);
            _console.Buffer.Should().BeEquivalentTo(new[]
            {
                "┌─── test progress ──┐",
                "│#####               │",
                "└────────────────────┘"
            });
            //end-snippet: ProgressCharBar
        }

As soon as you confirm this package is good enough and I have done some further testing, i will release a non alpha 6.3 update, and close this issue.

@MihailsKuzmins
Copy link
Author

Hey @goblinfactory (Alan)
Thank you for your hard work 🙏

Instead of 6.3 I tested it with the latest version which was release a while ago (namely 7.3.). For my request it was perfect, Current is exposed in the readonly mode, so even bar.Refresh(bar.Curent + 1) was possible in a while loop while (bar.Current <= bar.Max).

I think that my issue has been solved, so you could close it as soon as the new release is published in NuGet. 🤞

@goblinfactory
Copy link
Owner

Glad it works! Please note that version 7 has not been released yet, what you have fetched is an alpha release, so might be unstable. If you experience any issues let me know and i will try to address as quickly as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants