Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add high level module help #90

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/commands/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,39 @@ pub trait ServerCommands<'a> {
prepare_command(self, cmd("MODULE").arg("LIST"))
}

/// The command returns a helpful text describing the different MODULE subcommands.
///
/// # Return
/// An array of strings.
///
/// # Example
/// ```
/// # use rustis::{
/// # client::Client,
/// # commands::ServerCommands,
/// # Result,
/// # };
/// #
/// # #[cfg_attr(feature = "tokio-runtime", tokio::main)]
/// # #[cfg_attr(feature = "async-std-runtime", async_std::main)]
/// # async fn main() -> Result<()> {
/// # let client = Client::connect("127.0.0.1:6379").await?;
/// let result: Vec<String> = client.module_help().await?;
/// assert!(result.iter().any(|e| e == "HELP"));
/// # Ok(())
/// # }
/// ```
///
/// # See Also
/// [<https://redis.io/commands/module-help/>](https://redis.io/commands/module-help/)
#[must_use]
fn module_help(self) -> PreparedCommand<'a, Self, Vec<String>>
where
Self: Sized,
{
prepare_command(self, cmd("MODULE").arg("HELP"))
}

/// Loads a module from a dynamic library at runtime.
///
/// # See Also
Expand Down
12 changes: 12 additions & 0 deletions src/tests/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,18 @@ async fn memory_usage() -> Result<()> {
Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn module_help() -> Result<()> {
let client = get_test_client().await?;

let result: Vec<String> = client.module_help().await?;
assert!(result.iter().any(|e| e == "HELP"));

Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
Expand Down
Loading