{"id":24973082,"url":"https://github.com/myvas/cmdout","last_synced_at":"2026-02-13T03:32:45.910Z","repository":{"id":190536249,"uuid":"682857494","full_name":"myvas/cmdout","owner":"myvas","description":"The cmdout library provides facilities for executing shell commands and get their output before time runs out.","archived":false,"fork":false,"pushed_at":"2025-03-03T14:42:13.000Z","size":138,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T15:29:40.264Z","etag":null,"topics":["command-line","shell","stderr","stdout"],"latest_commit_sha":null,"homepage":"","language":"CMake","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/myvas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-08-25T03:20:33.000Z","updated_at":"2025-03-03T14:42:11.000Z","dependencies_parsed_at":"2023-08-25T04:59:42.561Z","dependency_job_id":"9360d0c9-420e-431e-9687-f75af64844e9","html_url":"https://github.com/myvas/cmdout","commit_stats":null,"previous_names":["myvas/cmdout"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myvas%2Fcmdout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myvas%2Fcmdout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myvas%2Fcmdout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myvas%2Fcmdout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myvas","download_url":"https://codeload.github.com/myvas/cmdout/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145086,"owners_count":20730495,"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":["command-line","shell","stderr","stdout"],"created_at":"2025-02-03T18:26:20.243Z","updated_at":"2026-02-13T03:32:40.892Z","avatar_url":"https://github.com/myvas.png","language":"CMake","readme":"# myvas::cmdout\n[![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/myvas/cmdout?label=github)](https://github.com/myvas/cmdout)\r\n[![GitHub Actions Status](https://github.com/myvas/cmdout/actions/workflows/test.yml/badge.svg)](https://github.com/myvas/cmdout/actions)\r\n[![Release](https://img.shields.io/github/release/myvas/cmdout.svg)](https://github.com/myvas/cmdout/releases)\r\n\r\nThe cmdout library provides facilities for executing shell commands and get their output before time runs out.\r\n\r\n## Getting Started\r\n### Import and link the library via CMake\r\n```\r\ninclude(FetchContent)\r\nFetchContent_Declare(cmdout\r\n\tURL https://github.com/myvas/cmdout/archive/refs/tags/0.2.0.tar.gz\r\n\tDOWNLOAD_EXTRACT_TIMESTAMP ON\r\n)\r\nFetchContent_MakeAvailable(cmdout)\r\n\r\ntarget_link_libraries(\u003cyour_target\u003e PRIVATE cmdout)\r\n```\r\n### Include the header file\r\n```\r\n#include \u003ccmdout/cmdout.h\u003e\r\n```\r\n\r\n### Examples\r\nC++17 on GNU/Linux Debian 11 (bullseye)\r\n```\r\n#include \u003ccmdout/cmdout_ext.h\u003e\r\n#include \u003ccassert\u003e\r\n//...\r\nint main() {\r\n\t// function myvas::system()\r\n\t{\r\n\t\tauto result = myvas::system(\"exit 0\");\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_SUCCESS);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::system(\"exit 1\");\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_FAILURE);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::system(\"ls not-exist 2\u003e\u00261\");\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == ENOENT);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::system_timeout(\"ls / -l\", std::chrono::milliseconds(0)).exec();\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_SUCCESS);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::system_timeout_ms(\"ls / -l\", 1);\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == ETIME);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::system_timeout_ms(\"ls / -l\", 9);\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_SUCCESS);\r\n\t}\r\n\r\n\t// class myvas::cmdout\r\n\t{\r\n\t\tauto result = myvas::cmdout().exec();\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_SUCCESS);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::cmdout(\"ls not-exist 2\u003e\u00261\").exec();\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_SUCCESS);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::cmdout(\"ls / -l\", std::chrono::milliseconds(1)).exec();\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == ETIME);\r\n\t}\r\n\t{\r\n\t\tauto result = myvas::cmdout(\"ls / -l\", std::chrono::milliseconds(9)).exec();\r\n\t\tstd::cout \u003c\u003c result \u003c\u003c std::endl;\r\n\t\tassert(result.status() == EXIT_SUCCESS);\r\n\t}\r\n}\r\n```\r\n\r\n## Tests\r\n```\r\nAll tests passed (33 assertions in 3 test cases)\r\n```\r\n\r\n## Benchmarks\r\n```\r\n./benchmarks/benchmarks\r\n2023-09-06T13:07:51+08:00\r\nRunning ./benchmarks\r\nRun on (4 X 2893.41 MHz CPU s)\r\nCPU Caches:\r\n  L1 Data 32 KiB (x2)\r\n  L1 Instruction 32 KiB (x2)\r\n  L2 Unified 256 KiB (x2)\r\n  L3 Unified 4096 KiB (x1)\r\nLoad Average: 1.81, 1.24, 0.94\r\n------------------------------------------------------------\r\nBenchmark                  Time             CPU   Iterations\r\n------------------------------------------------------------\r\nBM_std_system        1587179 ns        81671 ns         8562\r\nBM_std_system_out    1751184 ns       147665 ns         4749\r\nBM_myvas_system      1639949 ns       100367 ns         7086\r\nBM_myvas_cmdout      1760044 ns        56635 ns        12510\r\n```\r\n\r\n## For developers\r\n### FAQ 1. Could NOT find Doxygen (missing: dot) (found version \"1.9.5\")\r\nWe should install the doxygen and graphviz on the build/test/debug machine.\r\n(CMakeLists.txt Line: 119-123)\r\n```\r\napt install doxygen\r\napt install graphviz\r\n```\r\n\r\n### FAQ 2. How to install/upgrade cmake 3.27.0?\r\nWe should install the cmake 3.27.0 (or above) on the build/test/debug machine. [Here](https://askubuntu.com/questions/829310/how-to-upgrade-cmake-in-ubuntu) are steps on Debian:\r\n\r\n1.Check current version and location.\r\n```\r\ncmake --version\r\nwhich cmake\r\n```\r\n\r\n2.Download the installation script.\r\n```\r\nwget -b -c --show-progress  https://github.com/Kitware/CMake/releases/download/v3.27.0/cmake-3.27.0-linux-x86_64.sh\r\n```\r\n\r\n3.Run the script to unzip files.\r\n```\r\nsudo mv cmake-3.27.0-linux-x86_64.sh /opt\r\ncd /opt\r\nsudo bash cmake-3.27.0-linux-x86_64.sh\r\n```\r\n\r\n4.Replace old symbolic links.\r\n```\r\nsudo rm /usr/local/bin/ccmake\r\nsudo rm /usr/local/bin/cmake\r\nsudo rm /usr/local/bin/cmake-gui\r\nsudo rm /usr/local/bin/cpack\r\nsudo rm /usr/local/bin/ctest\r\nsudo ln /opt/cmake-3.27.0-linux-x86_64/bin/* /usr/local/bin\r\n```\r\n\r\n## Known issues\r\n- As of now, the feature is active on Linux, but it is not available for Windows, and there are no upcoming plans to make it compatible with Windows.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyvas%2Fcmdout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyvas%2Fcmdout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyvas%2Fcmdout/lists"}