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 default CLI response impl #142

Open
hu55a1n1 opened this issue Aug 1, 2024 · 0 comments
Open

Add default CLI response impl #142

hu55a1n1 opened this issue Aug 1, 2024 · 0 comments

Comments

@hu55a1n1
Copy link
Member

hu55a1n1 commented Aug 1, 2024

Summary

Seems like most of our CLI commands don't have anything specific to output, so we should provide a Response::default() impl that just serializes to an empty string.

Proposal

  • Impl Default for Response. e.g.
#[derive(Clone, Debug, Serialize)]
#[serde(untagged)]                         // <--------------------
pub enum Response {
    String(String),
    // ...
}

impl Default for Response {
    fn default() -> Self {
        Self::String("".to_string())
    }
}
  • Or make Response optional in the Handler trait, e.g.
    fn handle(self) -> Result<Option<Self::Response>, Self::Error>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant