{"id":20310839,"url":"https://github.com/progrium/go-shell","last_synced_at":"2025-07-06T00:38:42.899Z","repository":{"id":34909019,"uuid":"38952025","full_name":"progrium/go-shell","owner":"progrium","description":null,"archived":false,"fork":false,"pushed_at":"2019-04-05T04:47:18.000Z","size":13,"stargazers_count":310,"open_issues_count":2,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-20T08:01:46.785Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/progrium.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}},"created_at":"2015-07-12T06:09:43.000Z","updated_at":"2025-03-22T20:22:20.000Z","dependencies_parsed_at":"2022-08-26T14:22:44.887Z","dependency_job_id":null,"html_url":"https://github.com/progrium/go-shell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/progrium/go-shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgo-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgo-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgo-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgo-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/progrium","download_url":"https://codeload.github.com/progrium/go-shell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fgo-shell/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263832490,"owners_count":23517351,"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-11-14T17:34:45.462Z","updated_at":"2025-07-06T00:38:42.879Z","avatar_url":"https://github.com/progrium.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-shell\n\nLibrary to write \"shelling out\" Go code more shell-like,\nwhile remaining idiomatic to Go.\n\n## Features\n\n * Function-wrapper factories for shell commands\n * Panic on non-zero exits for `set -e` behavior\n * Result of `Run()` is a Stringer for STDOUT, has Error for STDERR\n * Heavily variadic function API `Cmd(\"rm\", \"-r\", \"foo\") == Cmd(\"rm -r\", \"foo\")`\n * Go-native piping `Cmd(...).Pipe(...)` or inline piping `Cmd(\"... | ...\")`\n * Template compatible \"last arg\" piping `Cmd(..., Cmd(..., Cmd(...)))`\n * Optional trace output mode like `set +x`\n * Similar variadic functions for paths and path templates\n\n## Examples\n\n```go\nimport (\n  \"fmt\"\n  \"github.com/progrium/go-shell\"\n)\n\nvar (\n  sh = shell.Run\n)\n\nshell.Trace = true // like set +x\nshell.Shell = []string{\"/bin/bash\", \"-c\"} // defaults to /bin/sh\n\nfunc main() {\n  defer shell.ErrExit()\n  sh(\"echo Foobar \u003e /foobar\")\n  sh(\"rm /fobar\") // typo raises error\n  sh(\"echo Done!\") // never run, program exited\n}\n```\n\n```go\nimport (\n  \"fmt\"\n  \"github.com/progrium/go-shell\"\n)\n\nfunc main() {\n  fmt.Println(shell.Cmd(\"echo\", \"foobar\").Pipe(\"wc\", \"-c\").Pipe(\"awk\", \"'{print $1}'\").Run())\n}\n```\n\n```go\nimport \"github.com/progrium/go-shell\"\n\nvar (\n  echo = shell.Cmd(\"echo\").OutputFn()\n  copy = shell.Cmd(\"cp\").ErrFn()\n  rm = shell.Cmd(\"rm\").ErrFn()\n)\n\nfunc main() {\n  err := copy(\"/foo\", \"/bar\")\n  // handle err\n  err = rm(\"/bar\")\n  // handle err\n  out, _ := echo(\"Done!\")\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fgo-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrium%2Fgo-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fgo-shell/lists"}