Crates.io | bubblers |
lib.rs | bubblers |
version | 0.1.0 |
source | src |
created_at | 2024-05-22 06:53:24.81075 |
updated_at | 2024-05-22 06:53:24.81075 |
description | Crustacean CLI that expels bubbles |
homepage | |
repository | https://github.com/warpy-ai/bubblers |
max_upload_size | |
id | 1247565 |
size | 65,919 |
Crustacean CLI that expels bubbles
Bubblers is a simple command line interface (CLI) builder in Rust. It provides rustubble built-in
To include Bubblers in your project, add the following to your Cargo.toml
:
[dependencies]
bubblers = "0.1.0"
Here is an example of how to create a basic CLI application using Bubblers:
use std::{sync::Arc, io};
use bubblers::{CliConfig, CommandConfig, CommandType, ArgConfig};
fn main() {
let mut cli = CliConfig::new("bubblers_app", "1.0", "A simple CLI app using Bubblers");
let command = CommandConfig::new_standard(
"greet",
"Print a greeting message",
Arc::new(|args| {
if let Some(name) = args.get(0) {
println!("Hello, {}!", name);
} else {
println!("Hello, world!");
}
}),
).add_arg(ArgConfig {
name: "name",
help: "Name to greet".to_string(),
required: false,
});
cli.add_command(command);
cli.execute();
}
Bubblers supports various UI elements. Here is an example of adding an input form:
cli.add_input(
"input",
"Get user input",
"Enter text here...",
"",
"Your Input:"
);
You can implement custom commands and add them to your CLI. Here's an example:
cli.add_command(CommandConfig::new_standard(
"custom_cmd",
"Execute a custom command",
Arc::new(|args| {
println!("Executing custom command with args: {:?}", args);
}),
));
Here's a full example of a CLI application using various features of Bubblers:
use std::{io, sync::Arc};
use bubblers::{CliConfig, CommandConfig, CommandType, ArgConfig};
use crossterm::style::Color;
fn main() {
let mut cli = CliConfig::new("bubblers_app", "1.0", "A simple CLI app using Bubblers");
// Standard Command
cli.add_command(CommandConfig::new_standard(
"greet",
"Print a greeting message",
Arc::new(|args| {
if let Some(name) = args.get(0) {
println!("Hello, {}!", name);
} else {
println!("Hello, world!");
}
}),
).add_arg(ArgConfig {
name: "name",
help: "Name to greet".to_string(),
required: false,
}));
// UI Command
cli.add_input(
"input",
"Get user input",
"Enter text here...",
"",
"Your Input:"
);
// UI with Return Command
cli.add_menu_list(
"menu",
"Select an option",
"Main Menu",
"Choose one of the following:",
vec!["Option 1".to_string(), "Option 2".to_string()]
);
cli.execute();
}
Contributions are welcome! Please submit a pull request or create an issue to discuss your ideas.
Bubblers is licensed under the MIT License. See LICENSE for more information.