mirror of https://github.com/djcb/mu.git
mu: extract Message::Options from command-line
This commit is contained in:
parent
7c51bc68d4
commit
66ee2004fc
|
@ -337,8 +337,6 @@ crypto_option_entries()
|
|||
static GOptionEntry entries[] = {
|
||||
{"auto-retrieve", 'r', 0, G_OPTION_ARG_NONE, &MU_CONFIG.auto_retrieve,
|
||||
"attempt to retrieve keys online (false)", NULL},
|
||||
{"use-agent", 'a', 0, G_OPTION_ARG_NONE, &MU_CONFIG.use_agent,
|
||||
"attempt to use the GPG agent (false)", NULL},
|
||||
{"decrypt", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.decrypt,
|
||||
"attempt to decrypt the message", NULL},
|
||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||
|
@ -722,10 +720,6 @@ Mu::mu_config_get_msg_options(const MuConfig* muopts)
|
|||
|
||||
if (muopts->decrypt)
|
||||
opts |= MU_MSG_OPTION_DECRYPT;
|
||||
if (muopts->verify)
|
||||
opts |= MU_MSG_OPTION_VERIFY;
|
||||
if (muopts->use_agent)
|
||||
opts |= MU_MSG_OPTION_USE_AGENT;
|
||||
if (muopts->auto_retrieve)
|
||||
opts |= MU_MSG_OPTION_AUTO_RETRIEVE;
|
||||
if (muopts->overwrite)
|
||||
|
@ -733,3 +727,16 @@ Mu::mu_config_get_msg_options(const MuConfig* muopts)
|
|||
|
||||
return (MuMsgOptions)opts;
|
||||
}
|
||||
|
||||
Message::Options
|
||||
Mu::mu_config_message_options(const MuConfig *conf)
|
||||
{
|
||||
Message::Options opts{};
|
||||
|
||||
if (conf->decrypt)
|
||||
opts |= Message::Options::Decrypt;
|
||||
if (conf->auto_retrieve)
|
||||
opts |= Message::Options::RetrieveKeys;
|
||||
|
||||
return opts;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** Copyright (C) 2008-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
** Copyright (C) 2008-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
|
@ -145,11 +145,8 @@ struct _MuConfig {
|
|||
/* options for crypto
|
||||
* ie, 'view', 'extract' */
|
||||
gboolean auto_retrieve; /* assume we're online */
|
||||
gboolean use_agent; /* attempt to use the gpg-agent */
|
||||
gboolean decrypt; /* try to decrypt the
|
||||
* message body, if any */
|
||||
gboolean verify; /* try to crypto-verify the
|
||||
* message */
|
||||
|
||||
/* options for view */
|
||||
gboolean terminator; /* add separator \f between
|
||||
|
@ -237,6 +234,15 @@ size_t mu_config_param_num(const MuConfig* conf);
|
|||
*/
|
||||
MuMsgOptions mu_config_get_msg_options(const MuConfig* opts);
|
||||
|
||||
/**
|
||||
* determine Message::Options from command line args
|
||||
*
|
||||
* @param opts a MuConfig struct
|
||||
*
|
||||
* @return the corresponding Message::Options
|
||||
*/
|
||||
Message::Options mu_config_message_options(const MuConfig* opts);
|
||||
|
||||
/**
|
||||
* print help text for the current command
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue