{"id":16868426,"url":"https://github.com/chen-keinan/go-command-eval","last_synced_at":"2025-03-22T07:30:57.746Z","repository":{"id":38332762,"uuid":"384163868","full_name":"chen-keinan/go-command-eval","owner":"chen-keinan","description":"Go-command-eval is an open-source which helps to execute a shell command and evaluate it results in a flexible ways","archived":false,"fork":false,"pushed_at":"2024-12-02T20:02:15.000Z","size":461,"stargazers_count":3,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T09:12:56.843Z","etag":null,"topics":["command","command-line","comparison","eval","executable","golang","linux-shell","shell","shell-command","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chen-keinan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-07-08T15:07:49.000Z","updated_at":"2024-09-08T12:33:16.000Z","dependencies_parsed_at":"2024-06-19T17:12:00.414Z","dependency_job_id":"69bc6fdb-bb7e-42b2-bb33-a450e68be62d","html_url":"https://github.com/chen-keinan/go-command-eval","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen-keinan%2Fgo-command-eval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen-keinan%2Fgo-command-eval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen-keinan%2Fgo-command-eval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen-keinan%2Fgo-command-eval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chen-keinan","download_url":"https://codeload.github.com/chen-keinan/go-command-eval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244924951,"owners_count":20532872,"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","command-line","comparison","eval","executable","golang","linux-shell","shell","shell-command","shell-script"],"created_at":"2024-10-13T14:58:16.970Z","updated_at":"2025-03-22T07:30:53.654Z","avatar_url":"https://github.com/chen-keinan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/chen-keinan/go-simple-config)](https://goreportcard.com/report/github.com/chen-keinan/go-simple-config)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/chen-keinan/go-command-eval/blob/master/LICENSE)\n\u003cimg src=\"./pkg/img/coverage_badge.png\" alt=\"test coverage badge\"\u003e\n[![Gitter](https://badges.gitter.im/beacon-sec/community.svg)](https://gitter.im/beacon-sec/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n\u003cbr\u003e\u003cimg src=\"./pkg/img/cmd_eval.png\" width=\"300\" alt=\"cmd_eval logo\"\u003e\u003cbr\u003e\n# go-command-eval\n\nGo-command-eval is an open source lib who evaluate shell command results against eval expr\n\n* [Installation](#installation)\n* [Usage](#usage)\n* [Contribution](#Contribution)\n\n\n## Installation\n\n```shell\ngo get github.com/chen-keinan/go-command-eval\n```\n\n## Usage\n### one shell command with single result evaluated against eval expression\n\ncreate shell command which return one result\n```go\nshCmd:=[]string{\"ls /etc/hosts | awk -F \\\" \\\" '{print $1}' |awk 'FNR \u003c= 1'\"}\n```\nevaluate command result with eval expression ( ${0} is the result from 1st shell command) \n```go\nevalExpr := \"'${0}' == '/etc/hosts'\"\n```\n\n### two shell commands with single result each evaluated with eval expression\n\ncreate two shell commands with one result for each\n```go\nshCmd := []string{\"ls /etc/hosts | awk -F \\\" \\\" '{print $1}' |awk 'FNR \u003c= 1'\",\n                    \"ls /etc/group | awk -F \\\" \\\" '{print $1}' |awk 'FNR \u003c= 1'\"}\n```\nevaluate each command result with eval expression\n```go\nevalExpr := \"'${0}' == '/etc/hosts'; \u0026\u0026 '${1}' == '/etc/group';\"\n```\n\n### shell command return two results evaluated with IN Clause eval expression\n\ncreate shell command with return two results\n```go\nshCmd := []string{\"ls /etc | awk -F \\\" \\\" '{print $1}' |awk 'FNR \u003c= 2'\"}\n```\nevaluate command result with IN Clause eval expression\n```go\nevalExpr := \"'${0}' IN ('afpovertcp.cfg','aliases')\"\n```\n\n### shell command result passed as an arg to the following shell command; both results are evaluated against eval expression\n\ncreate tow shell commands 1st command result passed as an arg to the following shell command\n```go\nshCmd := []string{\"ls /etc/hosts | awk -F \" \" '{print $1}' |awk 'FNR \u003c= 1'\",\n                    \"stat -f %A\" ${0}}\n```\nboth results are evaluated against eval expression 1st result is evaluated as string \n2nd result is evaluated as an Integer\n```go\nevalExpr := \"'${0}' == '/etc/hosts'; \u0026\u0026 ${1} \u003c= 766\"\n```\n\nFull code example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/chen-keinan/go-command-eval/eval\"\n)\n\nfunc main() {\n\tshCmd := []string{\"ls /etc/hosts | awk -F \\\" \\\" '{print $1}' |awk 'FNR \u003c= 1'\",\n\t\t\"ls /etc/group | awk -F \\\" \\\" '{print $1}' |awk 'FNR \u003c= 1'\"}\n\n\tevalExpr := \"'${0}' == '/etc/hosts'; \u0026\u0026 '${1}' == '/etc/group';\"\n\tcmdEvalResult := eval.NewEvalCmd().EvalCommand(shCmd, evalExpr)\n\tif cmdEvalResult.Match {\n\t\tfmt.Print(\"commmand result match eval expression\")\n\t}\n}\n```\n\n\n## Contribution\ncode contribution is welcome \ncontribution with passing tests and linter is more than welcome :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen-keinan%2Fgo-command-eval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchen-keinan%2Fgo-command-eval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen-keinan%2Fgo-command-eval/lists"}