{"id":26951025,"url":"https://github.com/arkady-emelyanov/go-shellparse","last_synced_at":"2026-04-09T08:46:21.200Z","repository":{"id":53175750,"uuid":"141579706","full_name":"arkady-emelyanov/go-shellparse","owner":"arkady-emelyanov","description":":shell: Parse strings à la shell","archived":false,"fork":false,"pushed_at":"2021-04-02T17:28:16.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-27T21:55:27.668Z","etag":null,"topics":["bash","parser","shell"],"latest_commit_sha":null,"homepage":"","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/arkady-emelyanov.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":"2018-07-19T12:57:09.000Z","updated_at":"2022-07-25T11:04:00.000Z","dependencies_parsed_at":"2022-09-14T09:51:58.245Z","dependency_job_id":null,"html_url":"https://github.com/arkady-emelyanov/go-shellparse","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkady-emelyanov%2Fgo-shellparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkady-emelyanov%2Fgo-shellparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkady-emelyanov%2Fgo-shellparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkady-emelyanov%2Fgo-shellparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arkady-emelyanov","download_url":"https://codeload.github.com/arkady-emelyanov/go-shellparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246911492,"owners_count":20853654,"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":["bash","parser","shell"],"created_at":"2025-04-02T23:35:29.274Z","updated_at":"2026-04-09T08:46:16.168Z","avatar_url":"https://github.com/arkady-emelyanov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parse strings à la shell\n\n[![GoDoc](https://godoc.org/github.com/arkady-emelyanov/go-shellparse?status.svg)](https://godoc.org/github.com/arkady-emelyanov/go-shellparse)\n[![Go Report Card](https://goreportcard.com/badge/github.com/arkady-emelyanov/go-shellparse)](https://goreportcard.com/report/github.com/arkady-emelyanov/go-shellparse)\n[![Codecov](https://codecov.io/gh/arkady-emelyanov/go-shellparse/branch/master/graph/badge.svg)](https://codecov.io/gh/arkady-emelyanov/go-shellparse)\n![CodeQL](https://github.com/arkady-emelyanov/go-shellparse/workflows/CodeQL/badge.svg)\n![CI Build](https://github.com/arkady-emelyanov/go-shellparse/actions/workflows/go.yml/badge.svg)\n\nWhenever you need parse command and arguments from a config file,\nyou facing quotes/escaping problem. Library hides complexity \nof parsing such strings.\n\n## Features\n\n* Ability to parse complex and multiline strings\n* Comments for multiline strings via `#` char\n* Useful helpers to parse string into:\n    * command and arguments\n    * map\n    * slice\n* Ability to expand variables like`${VAR}` with provided k/v map\n* DotEnv-like file parser\n* Remove unnecessary quotes from commands and arguments\n\n## Installation\n\n`go get -u github.com/arkady-emelyanov/go-shellparse`\n\n## Quick Start\n\nSimple usage:\n```\nbin, args, err := shellparse.Command(`bash -c 'echo \"It\\'s awesome\"'`)\n// bin: bash\n// args: []string{\"-c\", \"echo \\\"It's awesome\\\"\"}\n```\n\nWith current environment\n```\n// export SLEEP=1\n\nbin, args, err := shellparse.CommandWithEnv(`bash -c 'sleep ${SLEEP}'`)\n// bin: bash\n// args: []string{\"-c\", \"sleep 1\"}\n\n```\n\nWith custom variables:\n```\nvars := map[string]string{}{\n    \"USER\": \"johndoe\",\n}\nbin, args, err := shellparse.CommandWithMap(`echo ${USER}`, vars)\n// bin: echo\n// args: []string{\"johndoe\"}\n```\n\nIf string contains ${VAR} which is not present in provided map,\nerror will be raised. To avoid, escape variable in the following way: `\\${VAR}`.\n\n\u003e Please note, `*WithVars` functions will never lookup current environment directly. \nAll `key`=`value` var replacements expected to be present in a provided map.\n\n## Other helpers\n\n```\nparts, err := shellparse.StringToSlice(`one 'two' \"three\"`)\n// []string{\"one\", \"two\", \"three\"}\n\nparts, err := shellparse.StringToMap(`foo=bar foobar=baz`)\n// []map[string]string{\"foo\": \"bar\", \"foobar\": \"baz\"}\n```\n\n\u003e Library supports comments defined as `#` char. The rest of the line\nwill be ignored. \n\n## License\n\nLicensed under the [MIT License](http://www.opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkady-emelyanov%2Fgo-shellparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farkady-emelyanov%2Fgo-shellparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkady-emelyanov%2Fgo-shellparse/lists"}