{"id":16581702,"url":"https://github.com/kaushalmodi/version","last_synced_at":"2025-07-19T04:05:11.733Z","repository":{"id":77542068,"uuid":"265694814","full_name":"kaushalmodi/version","owner":"kaushalmodi","description":"Fetch and parse the version number of most CLI apps","archived":false,"fork":false,"pushed_at":"2021-07-01T16:16:53.000Z","size":94,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-14T10:44:20.006Z","etag":null,"topics":["api","cli","nim","version"],"latest_commit_sha":null,"homepage":"https://kaushalmodi.github.io/version/","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/kaushalmodi.png","metadata":{"files":{"readme":"README.org","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-20T21:59:06.000Z","updated_at":"2021-07-01T16:16:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"cab10353-9cd4-4564-8411-b565324d7e92","html_url":"https://github.com/kaushalmodi/version","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kaushalmodi/version","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaushalmodi","download_url":"https://codeload.github.com/kaushalmodi/version/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fversion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265887517,"owners_count":23844421,"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":["api","cli","nim","version"],"created_at":"2024-10-11T22:29:42.984Z","updated_at":"2025-07-19T04:05:11.724Z","avatar_url":"https://github.com/kaushalmodi.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+title: Fetch and parse the version for almost all CLI apps\n#+author: Kaushal Modi\n\n[[https://github.com/kaushalmodi/version/actions/workflows/test.yml][https://github.com/kaushalmodi/version/actions/workflows/test.yml/badge.svg]]\n[[https://github.com/kaushalmodi/version/actions/workflows/docs.yml][https://github.com/kaushalmodi/version/actions/workflows/docs.yml/badge.svg]]\n\n*version* provides a Nim library as well as a standalone CLI utility\n to fetch and parse the version info for almost any CLI app.\n\nThis project works for apps that use one of these switches to return\nthe version info:\n\n|-------------+---------------------------------------|\n| App switch  | Examples                              |\n|-------------+---------------------------------------|\n| *--version* | nim, GNU projects like gcc, emacs, rg |\n| *-V*        | tmux, p4                              |\n| *-v*        | tcc                                   |\n| *version*   | Go projects like hugo                 |\n|-------------+---------------------------------------|\n\n* Install\n#+begin_example\nnimble install https://github.com/kaushalmodi/version\n#+end_example\n* API Documentation\n[[https://kaushalmodi.github.io/version/][https://kaushalmodi.github.io/version/]]\n* Library\n** Compile time\n#+begin_src nim\nimport version\n\nstatic:\n  doAssert \"nim\".getVersionCT() == (NimMajor, NimMinor, NimPatch)\n  doAssert \"gcc\".getVersionCT() \u003e (9, 0, 0)\n#+end_src\n** Run time\n#+begin_src nim\nimport version\n\ndoAssert \"nim\".getVersion() == (NimMajor, NimMinor, NimPatch)\ndoAssert \"hugo\".getVersion() \u003e= (0, 60, 0)\n#+end_src\n* CLI Utility\n** Download\nIf you do not want to ~nimble install~ this package, you can download\nthe latest static binary (musl) for Linux 64-bit from [[https://github.com/kaushalmodi/version/releases][Releases]].\n** Input from terminal\n#+begin_example\nversion nim emacs hugo tcc perl tmux\n#+end_example\n\nAbove outputs:\n#+begin_example\nnim version: 1.3.5\n  Nim Compiler Version 1.3.5 [Linux: amd64]\n  Compiled at 2020-05-19\n  Copyright (c) 2006-2020 by Andreas Rumpf\n\n  git hash: e909486e5cde5a4a77cd6f21b42fc9ab38ec2ae6\n  active boot switches: -d:release\n\nemacs version: 27.0.91\n  GNU Emacs 27.0.91\n  Copyright (C) 2020 Free Software Foundation, Inc.\n  GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n  You may redistribute copies of GNU Emacs\n  under the terms of the GNU General Public License.\n  For more information about these matters, see the file named COPYING.\n\nhugo version: 0.71.0\n  Hugo Static Site Generator v0.71.0-06150C87 linux/amd64 BuildDate: 2020-05-18T16:08:02Z\n\ntcc version: 0.9.27\n  tcc version 0.9.27 (x86_64 Linux)\n\nperl version: 5.22.0\n  This is perl 5, version 22, subversion 0 (v5.22.0) built for x86_64-linux\n\n  Copyright 1987-2015, Larry Wall\n\n  Perl may be copied only under the terms of either the Artistic License or the\n  GNU General Public License, which may be found in the Perl 5 source kit.\n\n  Complete documentation for Perl, including FAQ lists, should be found on\n  this system using \"man perl\" or \"perldoc perl\".  If you have access to the\n  Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\ntmux version: 3.1.99\n  tmux next-3.2\n#+end_example\n** Input from a pipe\nThe arguments can also be piped into the ~version~ executable:\n#+begin_example\necho \"nim emacs hugo tcc perl tmux\" | version\n#+end_example\n* Prior art by others\n** semver\n[[https://github.com/euantorano/semver.nim][semver]] is a /semantic versioning parser for Nim/.\n\n*version* is a bit different than /semver/ because:\n- This is designed (or attempted to) to return a version tuple for any\n  CLI app.\n- The run time ~getVersion()~ and compile time ~getVersionCT()~ procs\n  return a *generic* 3-field tuple that can be right-away used with\n  Nim's inbuilt comparison operators.\n- This library also runs as a standalone binary which attempts to\n  return the version info for any application (issues/PR's are of\n  course welcome if you have an app that doesn't work with\n  this). Example: ~version nim emacs hugo gcc tcc tmux perl python~.\n* Known limitations\n** Versions of multiple tools on the same line\nSome tools like PyPy ([[https://github.com/kaushalmodi/version/issues/10#issue-622673454][ref]]) output versions of other tools as well on\nthe same line. While this issue doesn't happen specifically when\nrunning ~version pypy~, ~version~ will return the version of the wrong\ntool if that tool's version shows up first on the line. Here's a dummy\nexample:\n#+begin_example\n\u003e version mytool\nmytool version: 1.1.1\n  othertool 1.1.1 mytool 2.2.2\n#+end_example\n/But the good thing is that the full version string is also printed./\n** tcl\nTo find the Tcl version on your system, run:\n#+begin_src shell\necho 'puts [info patchlevel]; exit 0' | tclsh\n#+end_src\n[[https://stackoverflow.com/a/19189401/1219634][reference]]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaushalmodi%2Fversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaushalmodi%2Fversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaushalmodi%2Fversion/lists"}