///|
/// Custom Redis command with a typed result.
///
/// Use `Command` with `Client::execute` for commands that do not yet have a
/// typed helper. Pass command parts in Redis order, starting with the command
/// name, and provide a decoder for the response.
///
/// Example:
/// ```moonbit nocheck
/// let info = client.execute(
///   @redis.Command([b"INFO", b"server"], value => value.as_string()),
/// )
/// ```
struct Command[T] {
  args : Array[Bytes]
  res_decode_fn : (RawValue) -> T raise
}

///|
/// Creates a custom command from command parts and a response decoder.
///
/// Example:
/// ```moonbit nocheck
/// let cmd = @redis.Command([b"DBSIZE"], value => value.as_int())
/// ```
pub fn[T] Command::Command(
  args : Array[Bytes],
  res_decode_fn : (RawValue) -> T raise,
) -> Command[T] {
  { args, res_decode_fn }
}