1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! # Gmail format
//!
//! How much message detail the Gmail `get` commands ask for.
//!
//! Gmail exposes the same `format` query parameter on `messages.get`,
//! `drafts.get` and `threads.get`, so the three commands share one
//! [`ValueEnum`] rather than declare one each.
use clap::ValueEnum;
use io_gmail::v1::rest::messages::GmailMessageFormat;
/// Amount of Gmail message detail to return (`format` query parameter).
///
/// Defaults to `metadata`, which carries everything the commands print
/// without fetching bodies. Ask for `full` to get the MIME payload.
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
#[clap(rename_all = "kebab-case")]
pub enum FormatArg {
/// Identifiers and labels only, without headers or body.
Minimal,
/// The parsed payload: headers, MIME structure and bodies.
Full,
/// The whole message as raw RFC 5322 bytes.
Raw,
/// Headers only, narrowed down by the `--header` option.
#[default]
Metadata,
}
impl From<FormatArg> for GmailMessageFormat {
fn from(arg: FormatArg) -> Self {
match arg {
FormatArg::Minimal => GmailMessageFormat::Minimal,
FormatArg::Full => GmailMessageFormat::Full,
FormatArg::Raw => GmailMessageFormat::Raw,
FormatArg::Metadata => GmailMessageFormat::Metadata,
}
}
}