{"id":13903087,"url":"https://github.com/wena-cli/wena","last_synced_at":"2025-07-18T00:33:15.630Z","repository":{"id":37789944,"uuid":"477341153","full_name":"wena-cli/wena","owner":"wena-cli","description":"Wena is a micro-framework that provides an elegant starting point for your console application.","archived":false,"fork":false,"pushed_at":"2023-09-15T05:01:37.000Z","size":1004,"stargazers_count":258,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-25T11:39:58.278Z","etag":null,"topics":["cli","console","framework","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/wena-cli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-04-03T12:53:55.000Z","updated_at":"2024-10-23T21:38:21.000Z","dependencies_parsed_at":"2024-01-14T04:40:00.883Z","dependency_job_id":"607b58f4-7e90-4c4f-88c3-ed554e098dbf","html_url":"https://github.com/wena-cli/wena","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wena-cli/wena","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wena-cli%2Fwena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wena-cli%2Fwena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wena-cli%2Fwena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wena-cli%2Fwena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wena-cli","download_url":"https://codeload.github.com/wena-cli/wena/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wena-cli%2Fwena/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265685524,"owners_count":23811191,"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":["cli","console","framework","rust","rust-lang"],"created_at":"2024-08-06T22:01:36.720Z","updated_at":"2025-07-18T00:33:15.312Z","avatar_url":"https://github.com/wena-cli.png","language":"Rust","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg title=\"Wena\" width=\"50%\" src=\"https://raw.githubusercontent.com/wena-cli/wena/main/art/logo.png\" /\u003e\n    \u003cbr\u003e\n    \u003cimg alt=\"Wena code example\" width=\"80%\" src=\"https://raw.githubusercontent.com/wena-cli/wena/main/art/example.png\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://crates.io/crates/wena\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/wena\" alt=\"Build Status\"\u003e\u003c/img\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/wena-cli/wena/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/workflow/status/wena-cli/wena/Tests.svg\" alt=\"Build Status\"\u003e\u003c/img\u003e\u003c/a\u003e\n    \u003ca href=\"https://deps.rs/repo/github/wena-cli/wena\"\u003e\u003cimg src=\"https://deps.rs/repo/github/wena-cli/wena/status.svg\" alt=\"Dependency status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/wena-cli/wena/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-informational\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nWena was created by [Nuno Maduro](https://github.com/nunomaduro), and is a [Rust Lang](https://www.rust-lang.org) micro-framework that provides an elegant starting point for your console application.\n\n\u003e **This project is a work-in-progress**. Code and documentation are currently under development and are subject to change.\n\n------\n\n## Get Started\n\n\u003e **Requires [Rust 1.61.0](https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html)**\n\nFirst, install a recent release of Rust via the [rustup](https://rustup.rs):\n\n```sh\nrustup default stable\n```\n\nNext, create a new binary-based [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) project:\n\n```sh\ncargo new my-cli-application --bin\n```\n\nOnce the project is created, add `wena` as dependency in your `Cargo.yml`:\n\n```toml\n[dependencies]\nwena = \"0.2.0\"\n```\n\nAfter, modify your `src/main.rs` file, and create your CLI application:\n\n```rust\nuse wena::*;\n\nfn main() {\n    Application::new(\"calculator\")\n        .commands([Command::new(\"sum\")\n            .description(\"Add two numbers\")\n            .definition([\n                Argument::new(\"first\").required(true),\n                Argument::new(\"second\").required(true),\n            ])\n            .handler(|app| {\n                let first = app.input.argument::\u003ci32\u003e(\"first\").unwrap();\n                let second = app.input.argument::\u003ci32\u003e(\"second\").unwrap();\n\n                app.output.writeln(\n                    Alert::info(\n                        format!(\"Total: {}\", first + second)\n                    )\n                );\n\n                Ok(0)\n            })])\n        .run();\n}\n```\n\nFinally, compile and run the application with `cargo run`.\n\n```\ncargo run -q --\n```\n\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"Wena get started\" width=\"80%\" src=\"https://raw.githubusercontent.com/wena-cli/wena/main/art/get-started.png\" /\u003e\n\u003c/p\u003e\n\n## Application\n\nAs you may have noticed, Wena applications may be created using the struct `Application` that gets exported at the root level of the crate `wena`. And, the `new` static method allows you to create an instance of the struct `Application`:\n\n```rust\nuse wena::Application;\n\nlet app = Application::new(\"your-application-name\");\n```\n\nThe struct `Application` represents a command-line application, and as such, it contains a name, description, version, list of commands, an input implementation, and an output implementation.\n\nYou may run the application at any time using the method `run()`:\n\n```rust\nuse wena::Application;\n\nlet app = Application::new(\"your-application-name\")\n    .run();\n```\n\n### Description\n\nHaving a description is not required. You can optionally define a description using the `description()` method:\n\n```rust\nuse wena::Application\n\nlet app = Application::new(\"application-name\")\n    .description(\"Application description\");\n```\n\n### Version\n\nBy default, the application version is `1.0.0`. You can optionally define a version using the `version()` method:\n\n```rust\nuse wena::Application\n\nlet app = Application::new(\"application-name\")\n    .version(\"0.1.0\");\n```\n\n### Commands\n\nYou may run your application without any arguments to view all available commands in the application. Commands are defined using the `commands` method:\n\n```rust\nuse wena::{Application, Command, Output};\n\nlet app = Application::new(\"application-name\")\n    .commands([\n        Command::new(\"command-name\").handler(|app| {\n            // Command code...\n\n            Ok(0)\n        })\n    ]);\n```\n\n#### Command handler\n\nThe command's `handle()` method receives a closure that contains the logic you want the command to execute.\n\n```rust\nuse wena::Command\n\nlet command = Command::new(\"command-name\")\n    .handler(|app| {\n        // Command code...\n\n        Ok(0)\n    });\n```\n\nThe closure's first argument is an `Application` instance. As such, you have access to the application's `Input` and `Output` at any time in your command's code:\n\n```rust\nuse wena::Command\n\nlet command = Command::new(\"command-name\")\n    .handler(|app| {\n        let input = \u0026app.input;\n        let output = \u0026app.output;\n\n        Ok(0)\n    });\n```\n\nIn addition, the given handler should return a result with an `i32` [exit status](https://en.wikipedia.org/wiki/Exit_status). Keep in mind, that the given exit status is used internally by the framework that exit the current process.\n\n#### Command input\n\nThe command's input may be defined using the command's `definition` method:\n\n```rust\nuse wena::{Argument, Command};\n\nlet command = Command::new(\"command-name\")\n    .definition([\n        Argument::new(\"argument-name\").required(true),\n    ]);\n```\n\nWhen defined, input arguments may be accessed using the method `argument` in your command's code:\n\n```rust\nuse wena::{Argument, Command, Input};\n\nlet command = Command::new(\"command-name\")\n    .definition([\n        Argument::new(\"argument-name\").required(true),\n    ]).handler(|app| {\n        let value = app.input.argument::\u003cString\u003e(\"argument-name\");\n\n        Ok(0)\n    });\n```\n\nThe trait `Input` is required when using methods of the struct `Input`.\n\n#### Command output\n\nWhen necessary, you may write messages to the console using the command's output `write` or `writeln` methods:\n\n```rust\nuse wena::{Command, Output};\n\nlet command = Command::new(\"command-name\")\n    .handler(|app| {\n        // Outputs the given message...\n        app.output.write(\"My message\");\n\n        // Outputs the a new line...\n        app.output.new_line();\n\n        // Outputs the given message and a new line...\n        app.output.writeln(\"My message\");\n\n        Ok(0)\n    });\n```\n\nThe trait `Output` is required when using methods of the struct `Output`.\n\n## Colors and combinatorial style\n\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"Wena colors and combinatorial style\" width=\"50%\" src=\"https://raw.githubusercontent.com/wena-cli/wena/main/art/styling.png\" /\u003e\n\u003c/p\u003e\n\nWena lets you apply different styles to any `String` given to command's output methods. As such, when importing `colored::*;`, you may change the font color, background color, and combinatorial style such as bold, italics, dimmed, etc:\n\n```rust\nuse colored::*;\n\napp.output.writeln(\"My message\".bold().italic().green());\n```\n\n## Components\n\nWena gives you access the beautifully designed output components that give you everything you need to build CLI applications.\n\n### Alert\n\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"Wena alerts\" width=\"80%\" src=\"https://raw.githubusercontent.com/wena-cli/wena/main/art/alerts.png\" /\u003e\n\u003c/p\u003e\n\nAlerts provide contextual feedback messages for typical user actions.\n\n```rust\nuse wena::{Alert, Command, Output};\n\nlet command = Command::new(\"command-name\")\n    .handler(|app| {\n        app.output.writeln(Alert::error(\"This is a error — check it out!\"));\n        app.output.writeln(Alert::info(\"This is a info — check it out!\"));\n        app.output.writeln(Alert::warning(\"This is a warning — check it out!\"));\n\n        Ok(0)\n    );\n```\n\n## Utilities\n\nWena offers you several utilities that you may use to customize the nitty-gritty of your CLI application.\n\n### Terminal\n\nThe `Terminal` struct gives you access to multiple aspects of the user's terminal:\n\n```rust\nuse wena::Terminal;\n\nlet terminal = Terminal::default();\n\n// Computes the user's terminal width...\nlet width = terminal.width();\n```\n\n---\n\n## License\n\nWena is an open-source software licensed under the MIT license.\n","funding_links":[],"categories":["cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwena-cli%2Fwena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwena-cli%2Fwena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwena-cli%2Fwena/lists"}