{"id":39740588,"url":"https://github.com/nu11ptr/cliexpect","last_synced_at":"2026-01-18T11:14:26.235Z","repository":{"id":57552524,"uuid":"145308957","full_name":"nu11ptr/cliexpect","owner":"nu11ptr","description":"An expect client designed to work specifically with CLI shell interfaces","archived":false,"fork":false,"pushed_at":"2018-10-13T15:08:53.000Z","size":126,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T12:05:34.245Z","etag":null,"topics":["cli","expect","golang"],"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/nu11ptr.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-08-19T14:12:06.000Z","updated_at":"2021-01-07T22:28:15.000Z","dependencies_parsed_at":"2022-09-26T18:50:43.501Z","dependency_job_id":null,"html_url":"https://github.com/nu11ptr/cliexpect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nu11ptr/cliexpect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nu11ptr%2Fcliexpect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nu11ptr%2Fcliexpect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nu11ptr%2Fcliexpect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nu11ptr%2Fcliexpect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nu11ptr","download_url":"https://codeload.github.com/nu11ptr/cliexpect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nu11ptr%2Fcliexpect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28535160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["cli","expect","golang"],"created_at":"2026-01-18T11:14:26.161Z","updated_at":"2026-01-18T11:14:26.228Z","avatar_url":"https://github.com/nu11ptr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cliexpect \n[![Build Status](https://travis-ci.org/nu11ptr/cliexpect.svg?branch=master)](https://travis-ci.org/nu11ptr/cliexpect) [![Build status](https://ci.appveyor.com/api/projects/status/hcn04efhv6be9qef/branch/master?svg=true)](https://ci.appveyor.com/project/nu11ptr/cliexpect/branch/master) [![Coverage Status](https://coveralls.io/repos/github/nu11ptr/cliexpect/badge.svg?branch=master)](https://coveralls.io/github/nu11ptr/cliexpect?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/58fd89136467e9c5f5f2/maintainability)](https://codeclimate.com/github/nu11ptr/cliexpect/maintainability) [![codebeat badge](https://codebeat.co/badges/bc9f0e88-f744-4383-8a81-b0e6672f2fbd)](https://codebeat.co/projects/github-com-nu11ptr-cliexpect-master) [![Go Report Card](https://goreportcard.com/badge/github.com/nu11ptr/cliexpect)](https://goreportcard.com/report/github.com/nu11ptr/cliexpect) [![GoDoc](https://godoc.org/github.com/nu11ptr/cliexpect?status.svg)](https://godoc.org/github.com/nu11ptr/cliexpect)\n\nAn expect client designed to work specifically with CLI shell interfaces. Specifically, it always assumes a prompt will separate the data allowing easy traversal of multiple outputs. \n\nAdditionally,\nit always matches the text body as a 2nd pass after identifying the placement of it from the prompt. This allows matching to \"fail fast\" (the alternative is to match the body AND prompt at same time at which point if the body doesn't match even though the prompt does, your program will pause until the timeout is reached waiting to see if new data would match the regex - which it never would).\n\n# Usage\n\nA simple example of a typical use case:\n\n```go\n\t// Typical CLI output for the 'file' command (minus echo)\n\tinput := `user@host:~$ \ntest.py: ASCII text\nuser@host:~$ `\n\n\tsh := cliexpect.New(new(strings.Builder), strings.NewReader(input))\n\t// Setup the prompt regex based on the expected format\n\tsh.SetPromptRegex(`\\w+@\\w+:\\S+\\$ `)\n\n\t// NOTE: In real world, check for errors :-)\n\t_, groups, _ := sh.Retrieve()\n\tfmt.Printf(\"%q\\n\", groups)\n\n\tsh.SendLine(\"file test.py\")\n\n\t// Optional - since we now have the exact prompt, we can set it explcitely if we want\n\tsh.SetPrompt(groups[1])\n\t// The only thing we know is that it should list 'test.py' in the output - get the rest\n\t_, groups, _ = sh.ExpectRegex(\".*test.py.*\")\n\tfmt.Printf(\"%q\\n\", groups)\n```\n\nThe output is (the first string is matched text, the second the matched prompt):\n\n```go\n[\"\" \"user@host:~$ \"]\n[\"\\ntest.py: ASCII text\\n\" \"user@host:~$ \"]\n```\n\nPlay with cliexpect in your browser [here](https://play.jsgo.io/e9846a340391be92f7a311414d36eabe0f7f06d2)\n\n# Status\n\nIt is thought to be feature complete and stable and has a comprehensive test suite, however, it has seen very limited real world use. Use at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnu11ptr%2Fcliexpect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnu11ptr%2Fcliexpect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnu11ptr%2Fcliexpect/lists"}