{"id":27775278,"url":"https://github.com/annetutil/gnetcli","last_synced_at":"2026-05-19T12:01:41.722Z","repository":{"id":206520796,"uuid":"707864980","full_name":"annetutil/gnetcli","owner":"annetutil","description":"The ultimate solution for CLI automation in Golang","archived":false,"fork":false,"pushed_at":"2026-05-04T05:48:33.000Z","size":791,"stargazers_count":68,"open_issues_count":8,"forks_count":25,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-05-04T07:33:42.448Z","etag":null,"topics":["go","golang"],"latest_commit_sha":null,"homepage":"https://annetutil.github.io/gnetcli/","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/annetutil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-20T20:53:39.000Z","updated_at":"2026-05-04T05:48:39.000Z","dependencies_parsed_at":"2023-11-19T22:22:54.192Z","dependency_job_id":"e297ce19-ca67-4a79-924d-85ba34523150","html_url":"https://github.com/annetutil/gnetcli","commit_stats":null,"previous_names":["annetutil/gnetcli"],"tags_count":133,"template":false,"template_full_name":null,"purl":"pkg:github/annetutil/gnetcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annetutil%2Fgnetcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annetutil%2Fgnetcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annetutil%2Fgnetcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annetutil%2Fgnetcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/annetutil","download_url":"https://codeload.github.com/annetutil/gnetcli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/annetutil%2Fgnetcli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33215448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:54:09.561Z","status":"ssl_error","status_checked_at":"2026-05-19T07:54:08.508Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","golang"],"created_at":"2025-04-30T03:10:36.375Z","updated_at":"2026-05-19T12:01:41.688Z","avatar_url":"https://github.com/annetutil.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Gnetcli\n======\nThe ultimate solution for CLI automation in Golang. It provides a universal way to execute arbitrary commands using a CLI, eliminating the need for screen scraping with expect.\nThe project consist of go-library, GRPC server and CLI tool. It is typically used for automating network equipment such as Cisco, Juniper, Huawei, etc.\n\n## Feature Overview:\n* **Execute commands instead of just reading and writing.**\n* **Pager, questions and error handling are supported.**  \n  Describe CLI interface in a few expressions and get full power of the project.\n* **The project supports several network vendors, including Huawei, Juniper, Cisco, and RouterOS.**\n* **Netconf is supported.**  \n  Exec netconf in same manner as text command to simplify automation workflow.\n* **SSH tunneling is supported.**\n* **Clean output**  \n  Evaluation of terminal control codes and removal of echoes.\n* **[CLI](https://annetutil.github.io/gnetcli/basic_usage_cli/) and [GRPC-server](https://annetutil.github.io/gnetcli/basic_usage_server/) for interacting with non-Go projects and other automations**.\n\nDocumentation available [here](https://annetutil.github.io/gnetcli/).\n\n## Quick Start\n### Go-library\n\nInstallation in go project:\n\n```bash\ngo get -u github.com/annetutil/gnetcli\n```\n\nA program which execute `display interfaces` and return output, error and exit status.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"go.uber.org/zap\"\n\n\t\"github.com/annetutil/gnetcli/pkg/cmd\"\n\tdcreds \"github.com/annetutil/gnetcli/pkg/credentials\"\n\t\"github.com/annetutil/gnetcli/pkg/device/huawei\"\n\t\"github.com/annetutil/gnetcli/pkg/streamer/ssh\"\n)\n\nfunc main() {\n\thost := \"somehost\"\n\tpassword := \"mypassword\"\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\tlogger := zap.Must(zap.NewDevelopmentConfig().Build())\n\n\tcreds := dcreds.NewSimpleCredentials(\n\t\tdcreds.WithUsername(dcreds.GetLogin()),\n\t\tdcreds.WithSSHAgentSocket(dcreds.GetDefaultAgentSocket()), // try pubkey auth using agent\n\t\tdcreds.WithPassword(dcreds.Secret(password)), // and password\n\t\tdcreds.WithLogger(logger),\n\t)\n\tconnector := ssh.NewStreamer(host, creds, ssh.WithLogger(logger))\n\tdev := huawei.NewDevice(connector) // huawei CLI upon SSH\n\terr := dev.Connect(ctx)            // connection happens here\n\tif err != nil{\n\t\tpanic(err)\n    }\n\tdefer dev.Close()\n\tres, _ := dev.Execute(cmd.NewCmd(\"display interfaces\"))\n\tif res.Status() == 0 {\n\t\tfmt.Printf(\"Result: %s\\n\", res.Output())\n\t} else {\n\t\tfmt.Printf(\"Error: %s\\nStatus: %d\\n\", res.Status(), res.Error())\n\t}\n}\n```\n\n### CLI\n\n```shell\ngo install github.com/annetutil/gnetcli/cmd/cli@latest\ncli -hostname myhost -devtype huawei -debug -command $'dis clock\\ndis ver0' -password $password -json\n```\n\n```json\n[\n  {\n    \"output\": \"2023-10-29 10:00:00\\nSunday\\nTime Zone(UTC) : UTC\\n\",\n    \"error\": \"\",\n    \"status\": 0,\n    \"cmd\": \"dis clock\"\n  },\n  {\n    \"output\": \"\",\n    \"error\": \"              ^\\nError: Unrecognized command found at '^' position.\\n\",\n    \"status\": 1,\n    \"cmd\": \"dis ver0\"\n  }\n]\n```\n\n### GRPC-server\nInstall and start the server:\n```shell\ngo install github.com/annetutil/gnetcli/cmd/gnetcli_server@latest\nserver -debug -basic-auth mylogin:mysecret\n```\n\nExec a command on a device using GRPC \n```shell\nTOKEN=$(echo -n \"$LOGIN:$PASSWORD\" | base64)\ngrpcurl -H \"Authorization: Basic $TOKEN\" -plaintext -d '{\"host\": \"hostname\", \"cmd\": \"dis clock\", \"host_params\": {\"device\": \"huawei\", \"credentials\": {\"login\": \"test\", \"password\": \"test\"}}, \"string_result\": true}' localhost:50051 gnetcli.Gnetcli.Exec\n```\n\n## Start GRPC-server via docker\nClone the repository, build the image and run the container:\n```shell\ngit clone https://github.com/annetutil/gnetcli.git\ncd gnetcli\ndocker build -f image/Dockerfile -t gnetcli_server .\ndocker run -p 50051:50051 gnetcli_server\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fannetutil%2Fgnetcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fannetutil%2Fgnetcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fannetutil%2Fgnetcli/lists"}