{"id":13445514,"url":"https://github.com/Mpdreamz/shellprogressbar","last_synced_at":"2025-03-20T21:30:42.701Z","repository":{"id":11837756,"uuid":"14394012","full_name":"Mpdreamz/shellprogressbar","owner":"Mpdreamz","description":"ShellProgressBar - display progress in your console application","archived":false,"fork":false,"pushed_at":"2024-07-16T21:49:35.000Z","size":3558,"stargazers_count":1448,"open_issues_count":33,"forks_count":136,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-10-29T15:34:16.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mpdreamz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-14T12:11:55.000Z","updated_at":"2024-10-27T13:27:22.000Z","dependencies_parsed_at":"2024-01-28T20:05:24.577Z","dependency_job_id":"cc516fee-6177-4630-8260-fe6884405e36","html_url":"https://github.com/Mpdreamz/shellprogressbar","commit_stats":{"total_commits":57,"total_committers":23,"mean_commits":"2.4782608695652173","dds":0.631578947368421,"last_synced_commit":"dd596e14b46c28c005a06e315e05d9623987eeca"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mpdreamz%2Fshellprogressbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mpdreamz%2Fshellprogressbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mpdreamz%2Fshellprogressbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mpdreamz%2Fshellprogressbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mpdreamz","download_url":"https://codeload.github.com/Mpdreamz/shellprogressbar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244603414,"owners_count":20479823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:00:35.285Z","updated_at":"2025-03-20T21:30:42.695Z","avatar_url":"https://github.com/Mpdreamz.png","language":"C#","funding_links":[],"categories":["Frameworks, Libraries and Tools","C\\#","C#","框架, 库和工具"],"sub_categories":["GUI","图形用户界面GUI"],"readme":"ShellProgressBar\n===================\nvisualize (concurrent) progress in your console application\n\nThis is a great little library to visualize long running command line tasks.\n\n.NET Core ready!\n\nIt also supports spawning child progress bars which allows you to visualize dependencies and concurrency rather nicely.\n\nTested on OSX \n\n![example osx](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/pbar-osx.gif)\n\nand Windows \n\n![example win cmd](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/pbar-windows.gif)\n\n(Powershell works too, see example further down)\n\n# Install \n\nGet it on nuget: http://www.nuget.org/packages/ShellProgressBar/\n\n# Usage \n\nUsage is really straightforward\n\n```csharp\nconst int totalTicks = 10;\nvar options = new ProgressBarOptions\n{\n    ProgressCharacter = '─',\n    ProgressBarOnBottom = true\n};\nusing (var pbar = new ProgressBar(totalTicks, \"Initial message\", options))\n{\n    pbar.Tick(); //will advance pbar to 1 out of 10.\n    //we can also advance and update the progressbar text\n    pbar.Tick(\"Step 2 of 10\"); \n}\n```\n\n## Reporting progression\n\nThere are two ways to report progression. You can use the `Tick()` function as described above. Alternatively you can report progression through an [`IProgress\u003cT\u003e`](https://docs.microsoft.com/en-us/dotnet/api/system.iprogress-1) instance that you obtain by calling `AsProgress\u003cT\u003e()` on the progress bar object.\n\nFor a simple case where the progress type is a `float` value between 0.0 and 1.0 that represents the completion percentage, use `progressBar.AsProgress\u003cfloat\u003e()`:\n\n```csharp\nusing ProgressBar progressBar = new ProgressBar(10000, \"My Progress Message\");\nIProgress progress = progressBar.AsProgress\u003cfloat\u003e();\nprogress.Report(0.25); // Advances the progress bar to 25%\n```\n\nSee `IntegrationWithIProgressExample.cs` and `IntegrationWithIProgressPercentageExample.cs` in the [src/ShellProgressBar.Example/Examples](src/ShellProgressBar.Example/Examples) directory for full examples.\n\n## Options\n\n### Progress bar position\n\n```csharp\nconst int totalTicks = 10;\nvar options = new ProgressBarOptions\n{\n\tProgressCharacter = '─',\n\tProgressBarOnBottom = true\n};\nusing (var pbar = new ProgressBar(totalTicks, \"progress bar is on the bottom now\", options))\n{\n\tTickToCompletion(pbar, totalTicks, sleep: 500);\n}\n```\n\nBy default the progress bar is at the top and the message at the bottom.\nThis can be flipped around if so desired.\n\n![bar_on_bottom](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/bar-on-bottom-osx.gif)\n\n### Styling changes\n\n```csharp\nconst int totalTicks = 10;\nvar options = new ProgressBarOptions\n{\n\tForegroundColor = ConsoleColor.Yellow,\n\tForegroundColorDone = ConsoleColor.DarkGreen,\n\tBackgroundColor = ConsoleColor.DarkGray,\n\tBackgroundCharacter = '\\u2593'\n};\nusing (var pbar = new ProgressBar(totalTicks, \"showing off styling\", options))\n{\n\tTickToCompletion(pbar, totalTicks, sleep: 500);\n}\n```\n\nMany aspects can be styled including foreground color, background (inactive portion)\nand changing the color on completion.\n\n![styling](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/styling-windows.gif)\n\n\n### No real time update\n\nBy default a timer will draw the screen every 500ms. You can configure the progressbar \nto only be drawn when `.Tick()` is called.\n\n```csharp\nconst int totalTicks = 5;\nvar options = new ProgressBarOptions\n{\n\tDisplayTimeInRealTime = false\n};\nusing (var pbar = new ProgressBar(totalTicks, \"only draw progress on tick\", options))\n{\n\tTickToCompletion(pbar, totalTicks, sleep:1750);\n}\n```\n\nIf you look at the time passed you will see it skips `02:00`\n\n\n![update_on_tick](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/update-on-tick-osx.gif)\n\n### Descendant progressbars\n\nA progressbar can spawn child progress bars and each child can spawn\nits own progressbars. Each child can have its own styling options.\n\nThis is great to visualize concurrent running tasks.\n\n```csharp\nconst int totalTicks = 10;\nvar options = new ProgressBarOptions\n{\n\tForegroundColor = ConsoleColor.Yellow,\n\tBackgroundColor = ConsoleColor.DarkYellow,\n\tProgressCharacter = '─'\n};\nvar childOptions = new ProgressBarOptions\n{\n\tForegroundColor = ConsoleColor.Green,\n\tBackgroundColor = ConsoleColor.DarkGreen,\n\tProgressCharacter = '─'\n};\nusing (var pbar = new ProgressBar(totalTicks, \"main progressbar\", options))\n{\n\tTickToCompletion(pbar, totalTicks, sleep: 10, childAction: () =\u003e\n\t{\n\t\tusing (var child = pbar.Spawn(totalTicks, \"child actions\", childOptions))\n\t\t{\n\t\t\tTickToCompletion(child, totalTicks, sleep: 100);\n\t\t}\n\t});\n}\n```\n\n![children](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/children-osx.gif)\n\nBy default children will collapse when done, making room for new/concurrent progressbars.\n\nYou can keep them around by specifying `CollapseWhenFinished = false`\n\n```csharp\nvar childOptions = new ProgressBarOptions\n{\n\tForegroundColor = ConsoleColor.Green,\n\tBackgroundColor = ConsoleColor.DarkGreen,\n\tProgressCharacter = '─',\n\tCollapseWhenFinished = false\n};\n```\n\n![children_no_collapse](https://github.com/Mpdreamz/shellprogressbar/raw/master/doc/children-no-collapse-windows.gif)\n\n\n# FixedDurationBar\n\n`ProgressBar` is great for visualizing tasks with an unknown runtime. If you have a task that you know takes a fixed amount of time there is also a `FixedDurationBar` subclass.\n`FixedDurationBar` will `Tick()` automatically but other then that all the options and usage are the same. Except it relies on the real time update feature so disabling that \nwill throw.\n\n`FixedDurationBar` exposes an `IsCompleted` and `CompletedHandle` \n\n\n### Credits \n\nThe initial implementation was inspired by this article.\nhttp://www.bytechaser.com/en/articles/ckcwh8nsyt/display-progress-bar-in-console-application-in-c.aspx\n\nAnd obviously anyone who sends a PR to this repository :+1:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMpdreamz%2Fshellprogressbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMpdreamz%2Fshellprogressbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMpdreamz%2Fshellprogressbar/lists"}