{"id":37021039,"url":"https://github.com/l2x6/cli-assured","last_synced_at":"2026-01-14T02:28:10.998Z","repository":{"id":327477590,"uuid":"1109478776","full_name":"l2x6/cli-assured","owner":"l2x6","description":"Java DSL for testing command line applications","archived":false,"fork":false,"pushed_at":"2025-12-14T22:47:43.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-15T06:26:39.721Z","etag":null,"topics":["cli","java","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","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/l2x6.png","metadata":{"files":{"readme":"README.adoc","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-03T21:30:45.000Z","updated_at":"2025-12-14T22:47:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/l2x6/cli-assured","commit_stats":null,"previous_names":["l2x6/cli-assured"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/l2x6/cli-assured","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2x6%2Fcli-assured","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2x6%2Fcli-assured/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2x6%2Fcli-assured/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2x6%2Fcli-assured/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/l2x6","download_url":"https://codeload.github.com/l2x6/cli-assured/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2x6%2Fcli-assured/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","java","testing"],"created_at":"2026-01-14T02:28:10.374Z","updated_at":"2026-01-14T02:28:10.989Z","avatar_url":"https://github.com/l2x6.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= CLI Assured\n\nhttps://github.com/l2x6/cli-assured/blob/main/LICENSE[image:https://img.shields.io/github/license/l2x6/cli-assured.svg[License]]\nhttps://central.sonatype.com/artifact/org.l2x6.cli-assured/cli-assured[image:https://img.shields.io/maven-central/v/org.l2x6.cli-assured/cli-assured.svg[Maven\nCentral]]\n\nA Java DSL for testing command line applications.\n\nRequires Java 8+\n\n== Maven coordinates\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.l2x6.cli-assured\u003c/groupId\u003e\n  \u003cartifactId\u003ecli-assured\u003c/artifactId\u003e\n  \u003cversion\u003e\u003c!-- Use the latest --\u003e\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nFind the latest version on https://central.sonatype.com/artifact/org.l2x6.cli-assured/cli-assured[Maven Central].\n\n== Usage\n\n=== Basic syntax\n\nTest an executable available in `PATH`\n\n[source,java]\n----\nimport org.l2x6.cli.assured.CliAssured;\n\nCliAssured\n    .command(\"echo\", \"CLI Assured rocks!\")\n    .stderrToStdout() // redirect stderr to stdout\n    .then()\n        // Assertions for stdout\n        // The same can be done with stderr(), unless you called stderrToStdout()\n        .stdout()\n            .hasLines(\"CLI Assured rocks!\")\n            .hasLinesContaining(\"rocks\")\n            .hasLinesMatching(\"CLI.*rocks\")\n            .doesNotHaveLinesContainingCaseInsensitive(\"error\")\n            .log() // Pass every line to org.l2x6.cli.assured.stdout logger\n            .hasLineCount(1)\n            .redirect(Path.of(\"hello.txt\")) // redirect the output to hello.txt\n        .exitCodeIs(0) // could be omitted as exit code 0 is enforced by default\n    .execute()\n    .assertSuccess(); // Report all assertion errors\n----\n\n=== Given-when-then\n\nIf you are a fan of Behavior-Driven testing, there is some syntactic sugar for you:\n\n[source,java]\n----\nimport org.l2x6.cli.assured.CliAssured;\n\nCliAssured\n    .given()\n        .env(\"MESSAGE\", \"CLI Assured rocks!\")\n    .when()\n        .command(\"sh\", \"-c\",\n                    \"echo $MESSAGE;\"\n                  + \"echo Really! 1\u003e\u00262\")\n    .then()\n        .stdout()\n            .hasLines(\"CLI Assured rocks!\")\n            .hasLineCount(1)\n        .stderr()\n            .hasLines(\"Really!\")\n            .hasLineCount(1)\n        .exitCodeIs(0)\n    .execute()\n    .assertSuccess();\n----\n\n=== `stdin`\n\n[source,java]\n----\nimport org.l2x6.cli.assured.CliAssured;\n\nCliAssured\n    .given()\n        .stdin(\"Hello world!\")\n    .when()\n        .command(\"cat\")\n    .then()\n        .stdout()\n            .hasLines(\"Hello world!\")\n            .hasLineCount(1)\n    .execute()\n    .assertSuccess();\n----\n\n=== `CliAssured.java()` - call the `java` executable of the current JVM\n\nSometimes it comes in handy to call the `java` executable of the current JVM.\n\nFor example\n\n[source,java]\n----\nimport org.l2x6.cli.assured.CliAssured;\n\nCliAssured\n    .java()\n        .args(\"-jar\", \"path/to/my.jar\")\n    .execute()\n    .assertSuccess();\n----\n\nOr if you want to compile and run a single java file, such as\n\n[source,java]\n.Hello.java\n----\npublic class Hello {\n    public static void main(String[] args) {\n        System.out.println(\"Hello \" + args[0]);\n    }\n}\n----\n\nit can be done as follows\n\n[source,java]\n----\nimport org.l2x6.cli.assured.CliAssured;\n...\n\nCliAssured\n    .java()\n       .args(\"path/to/Hello.java\", \"Joe\")\n    .then()\n        .stdout()\n            .hasLines(\"Hello Joe\")\n    .execute()\n    .assertSuccess();\n----\n\n== `mvn-assured` - a Java DSL for invoking an testing Maven\n\n=== Maven coordinates\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.l2x6.cli-assured\u003c/groupId\u003e\n  \u003cartifactId\u003emvn-assured\u003c/artifactId\u003e\n  \u003cversion\u003e\u003c!-- Use the latest --\u003e\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nFind the latest version on https://central.sonatype.com/artifact/org.l2x6.cli-assured/mvn-assured[Maven Central].\n\n=== Usage\n\n[source,java]\n----\nMvn.version(\"3.9.11\")\n    .installIfNeeded() // installs Maven from\n                       // https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip\n                       // to ~/.m2/wrapper/dists/apache-maven-3.9.11/a2d47e15\n                       // much like Maven Wrapper would do.\n\n    .args(\"--version\") // Returns an org.l2x6.cli.assured.CommandSpec,\n                       // so the rest is a standard cli-assured code\n    .then()\n        .stdout()\n            .hasLines(\"Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b)\")\n    .execute()\n    .assertSuccess();\n----\n\nOr alternatively,\n\n[source,java]\n----\nMvn.fromMvnw(Paths.get(\".\")) // Find .mvn/wrapper/maven-wrapper.properties\n                             // under the nearest ancestor,\n                             // extract the distribution URL from there\n                             // find Maven version from the distribution URL\n                             // and use all of that to create a new Mvn instance\n\n    .installIfNeeded() // You can omit this, if you are sure mvnw was run before\n\n    .args(\"--version\") // Returns an org.l2x6.cli.assured.CommandSpec,\n                       // so the rest is a standard cli-assured code\n    .then()\n        .stdout()\n            .hasLines(\"Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b)\")\n    .execute()\n    .assertSuccess();\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2x6%2Fcli-assured","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl2x6%2Fcli-assured","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2x6%2Fcli-assured/lists"}