Skip to content

Commit

Permalink
impl high level command - config help (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemIsmagilov authored Dec 22, 2024
1 parent afbde24 commit 3a678e6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/commands/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,38 @@ pub trait ServerCommands<'a> {
prepare_command(self, cmd("CONFIG").arg("GET").arg(params))
}

/// The command returns a helpful text describing the different CONFIG 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.config_help().await?;
/// assert!(result.iter().any(|e| e == "HELP"));
/// # Ok(())
/// # }
/// ```
/// # See Also
/// [<https://redis.io/commands/config-help/>](https://redis.io/commands/config-help/)
#[must_use]
fn config_help(self) -> PreparedCommand<'a, Self, Vec<String>>
where
Self: Sized,
{
prepare_command(self, cmd("CONFIG").arg("HELP"))
}

/// Resets the statistics reported by Redis using the [`info`](ServerCommands::info) command.
///
/// # See Also
Expand Down
11 changes: 11 additions & 0 deletions src/tests/server_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,17 @@ async fn config_get() -> Result<()> {
Ok(())
}

#[cfg_attr(feature = "tokio-runtime", tokio::main)]
#[cfg_attr(feature = "async-std-runtime", async_std::main)]
#[serial]
async fn config_help() -> Result<()> {
let client = get_test_client().await?;
let result: Vec<String> = client.config_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

0 comments on commit 3a678e6

Please sign in to comment.