From: Thomas Roessler Date: Wed, 13 Nov 2002 10:07:03 +0000 (+0000) Subject: Add a new command line option -A which is used to expand aliases. X-Git-Tag: mutt-1-5-2-rel~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e857760cdaddc72c6b9adc78f92f7ef3c2df81e6;p=mutt Add a new command line option -A which is used to expand aliases. --- diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index 96cdc1dc..1c26f516 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -2875,6 +2875,7 @@ mailbox. However, it is possible to read other mailboxes and to send messages from the command line as well. +-A expand an alias -a attach a file to a message -b specify a blind carbon-copy (BCC) address -c specify a carbon-copy (Cc) address diff --git a/doc/mutt.man b/doc/mutt.man index 4dc8b8bd..31226614 100644 --- a/doc/mutt.man +++ b/doc/mutt.man @@ -44,6 +44,9 @@ mutt \- The Mutt Mail User Agent .B mutt [-n] [-e \fIcmd\fP] [-F \fIfile\fP] -Q \fIquery\fP .PP +.B mutt +[-n] [-e \fIcmd\fP] [-F \fIfile\fP] -A \fIalias\fP +.PP .B mutt -v[v] .SH DESCRIPTION @@ -53,6 +56,8 @@ mail under unix operating systems, including support color terminals, MIME, and a threaded sorting mode. .SH OPTIONS .PP +.IP "-A \fIalias\fP" +An expanded version of the given alias is passed to stdout. .IP "-a \fIfile\fP" Attach a file to your message using MIME. .IP "-b \fIaddress\fP" diff --git a/main.c b/main.c index d2091a00..aced3118 100644 --- a/main.c +++ b/main.c @@ -87,6 +87,7 @@ static void mutt_usage (void) puts _( "usage: mutt [ -nRyzZ ] [ -e ] [ -F ] [ -m ] [ -f ]\n\ mutt [ -nR ] [ -e ] [ -F ] -Q [ -Q ] [...]\n\ + mutt [ -nR ] [ -e ] [ -F ] -A [ -A ] [...]\n\ mutt [ -nx ] [ -e ] [ -a ] [ -F ] [ -H ] [ -i ] [ -s ] [ -b ] [ -c ] [ ... ]\n\ mutt [ -n ] [ -e ] [ -F ] -p\n\ mutt -v[v]\n\ @@ -468,6 +469,7 @@ int main (int argc, char **argv) LIST *attach = NULL; LIST *commands = NULL; LIST *queries = NULL; + LIST *alias_queries = NULL; int sendflags = 0; int flags = 0; int version = 0; @@ -502,9 +504,12 @@ int main (int argc, char **argv) memset (Options, 0, sizeof (Options)); memset (QuadOptions, 0, sizeof (QuadOptions)); - while ((i = getopt (argc, argv, "a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) + while ((i = getopt (argc, argv, "A:a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) switch (i) { + case 'A': + alias_queries = mutt_add_list (alias_queries, optarg); + break; case 'a': attach = mutt_add_list (attach, optarg); break; @@ -615,7 +620,7 @@ int main (int argc, char **argv) } /* Check for a batch send. */ - if (!isatty (0) || queries) + if (!isatty (0) || queries || alias_queries) { set_option (OPTNOCURSES); sendflags = SENDBATCH; @@ -632,6 +637,23 @@ int main (int argc, char **argv) if (queries) return mutt_query_variables (queries); + + if (alias_queries) + { + int rv = 0; + ADDRESS *a; + for (; alias_queries; alias_queries = alias_queries->next) + { + if ((a = mutt_lookup_alias (alias_queries->data))) + mutt_write_address_list (a, stdout, 0); + else + { + rv = 1; + printf ("%s\n", alias_queries->data); + } + } + return rv; + } if (newMagic) mx_set_magic (newMagic); diff --git a/protos.h b/protos.h index f8e20afc..30aa9f89 100644 --- a/protos.h +++ b/protos.h @@ -230,6 +230,7 @@ void mutt_update_encoding (BODY *a); void mutt_update_tree (ATTACHPTR **, short); void mutt_version (void); void mutt_view_attachments (HEADER *); +void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen); void mutt_set_virtual (CONTEXT *); int mutt_addr_is_user (ADDRESS *);