{"id":26600810,"url":"https://github.com/de-odex/suru","last_synced_at":"2025-04-09T16:24:13.795Z","repository":{"id":42372483,"uuid":"262935511","full_name":"de-odex/suru","owner":"de-odex","description":"A tqdm-style progress bar in Nim","archived":false,"fork":false,"pushed_at":"2024-03-12T13:53:26.000Z","size":18092,"stargazers_count":68,"open_issues_count":5,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-23T18:48:02.734Z","etag":null,"topics":["nim","nim-lang","nim-language","progress-bar","progressbar"],"latest_commit_sha":null,"homepage":"","language":"Nim","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/de-odex.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":"2020-05-11T04:10:20.000Z","updated_at":"2025-02-06T21:06:19.000Z","dependencies_parsed_at":"2025-03-23T18:47:49.005Z","dependency_job_id":null,"html_url":"https://github.com/de-odex/suru","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-odex%2Fsuru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-odex%2Fsuru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-odex%2Fsuru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-odex%2Fsuru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/de-odex","download_url":"https://codeload.github.com/de-odex/suru/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248066060,"owners_count":21042030,"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":["nim","nim-lang","nim-language","progress-bar","progressbar"],"created_at":"2025-03-23T18:35:32.530Z","updated_at":"2025-04-09T16:24:13.759Z","avatar_url":"https://github.com/de-odex.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"suru\n====\n\nA tqdm-style progress bar in Nim\n\n![asciicast](https://raw.githubusercontent.com/de-odex/suru/master/demo.gif)\n\nthe demo above uses this code (note that the api has since changed, refer to tests/tests.nim for updated code):\n```nim\nimport unittest, os, sequtils, random\nrandomize()\n\ntest \"random time test\":\n  for a in suru(toSeq(0..\u003c100)):\n    sleep((rand(99) + 1))\n\ntest \"long time test\":\n  for a in suru([1, 2, 3, 5]):\n    sleep(1000)\n\ntest \"alternate long time test\":\n  sleep 1000\n  var bar: SuruBar = initSuruBar(25)\n\n  bar.start(4)\n\n  for a in toSeq(1..1000):\n    sleep 4\n    if a mod 250 == 0:\n      inc bar\n    bar.update(50_000_000)\n\n  bar.finish()\n\ntest \"constant time test\":\n  for a in suru(toSeq(0..\u003c100)):\n    sleep(25)\n\ntest \"v-shaped time test\":\n  for a in suru(toSeq(1..100) \u0026 toSeq(countdown(100, 1))):\n    sleep(a)\n\ntest \"increasing time test\":\n  for a in suru(toSeq(1..100)):\n    sleep(a)\n\ntest \"sinusoidal time test\":\n  for a in suru(toSeq(1..100)):\n    sleep(int(sin(a.float / 5) * 50 + 50))\n\ntest \"multi-bar test\":\n  echo \"check if this line is removed by the bars\"\n  sleep 1000\n  var bar: SuruBar = initSuruBar(25, 25)\n\n  bar.start(1000, 40)\n\n  for a in toSeq(1..1000):\n    sleep 25\n    inc bar\n    if a mod 25 == 0:\n      inc bar, 1\n    bar.update(50_000_000)\n    bar.update(50_000_000, 1)\n\n  bar.finish()\n\n  echo \"check if this line is removed by the bars\"\n```\n\nUsage\n-----\nsuru can be used in two ways:\n```nim\nimport suru\n\nfor a in suru([20, 90, 120]):\n  # do something\n  discard\n```\n\nor\n\n```nim\nimport suru\n\nvar bar: SuruBar = initSuruBar()\n# pass in a positive integer if you want to change how many bars there are\n\nbar[0].total = 3 # number of iterations\n\nbar.setup()\n\nfor a in [20, 90, 120]:\n  # do something\n\n  inc bar # can be changed to increment n amount at a time\n  # will increment all bars\n  # use inc bar[0] if you only want to increment the first bar\n\n  bar.update(50_000_000) # in nanoseconds, so the delay is 50 ms\n  # will be clamped to at least 1 ms\n\nbar.finish()\n```\n\nAPI Reference\n-------------\nTODO :(\n\nMajor To-do\n-----------\nthe order bears no meaning\n\n- [ ] thread-safe\n- [x] multi-bar support\n- [x] formatting support\n  - [x] ascii-only version\n  - [x] custom text\n- [ ] stable api\n  - might come soon, i need more opinions on the current api\n- [x] iterator support\n- [ ] unicode checks\n- [ ] echoing within the loop\n- [ ] recursive support for suru macro\n  - ex: (this should work like manually making a two-bar SuruBar)\n```nim\nimport suru\n\nfor a in suru(...):\n  # do something\n  for b in suru(...):\n    # do another thing\n```\n\nDependencies\n------------\nsuru has no external Nim dependencies\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fde-odex%2Fsuru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fde-odex%2Fsuru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fde-odex%2Fsuru/lists"}