Implemented -a (--append) option. Rewrite the support for -s using -a.
Showing
1 changed file
with
17 additions
and
4 deletions
... | @@ -45,7 +45,8 @@ static struct argp_option options[] = { | ... | @@ -45,7 +45,8 @@ static struct argp_option options[] = { |
45 | {"subject", 's', N_("SUBJ"), 0, N_("Send a message with a Subject of SUBJ"), 0}, | 45 | {"subject", 's', N_("SUBJ"), 0, N_("Send a message with a Subject of SUBJ"), 0}, |
46 | {"to", 't', 0, 0, N_("Precede message by a list of addresses"), 0}, | 46 | {"to", 't', 0, 0, N_("Precede message by a list of addresses"), 0}, |
47 | {"user", 'u', N_("USER"), 0, N_("Operate on USER's mailbox"), 0}, | 47 | {"user", 'u', N_("USER"), 0, N_("Operate on USER's mailbox"), 0}, |
48 | 48 | {"append", 'a', N_("HEADER: VALUE"), 0, | |
49 | N_("Append given header to the message being sent."), 0}, | ||
49 | { NULL, 0, NULL, 0, NULL, 0 } | 50 | { NULL, 0, NULL, 0, NULL, 0 } |
50 | }; | 51 | }; |
51 | 52 | ||
... | @@ -55,6 +56,7 @@ struct arguments | ... | @@ -55,6 +56,7 @@ struct arguments |
55 | char **args; | 56 | char **args; |
56 | char *file; | 57 | char *file; |
57 | char *user; | 58 | char *user; |
59 | int send_mode; | ||
58 | }; | 60 | }; |
59 | 61 | ||
60 | static error_t | 62 | static error_t |
... | @@ -64,6 +66,11 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -64,6 +66,11 @@ parse_opt (int key, char *arg, struct argp_state *state) |
64 | 66 | ||
65 | switch (key) | 67 | switch (key) |
66 | { | 68 | { |
69 | case 'a': | ||
70 | args->send_mode = 1; | ||
71 | send_append_header (arg); | ||
72 | break; | ||
73 | |||
67 | case 'e': | 74 | case 'e': |
68 | util_cache_command (&command_list, "set mode=exist"); | 75 | util_cache_command (&command_list, "set mode=exist"); |
69 | break; | 76 | break; |
... | @@ -112,9 +119,9 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -112,9 +119,9 @@ parse_opt (int key, char *arg, struct argp_state *state) |
112 | break; | 119 | break; |
113 | 120 | ||
114 | case 's': | 121 | case 's': |
115 | util_cache_command (&command_list, "set mode=send"); | 122 | send_append_header2 (MU_HEADER_SUBJECT, arg, COMPOSE_REPLACE); |
116 | util_cache_command (&command_list, "set noasksub"); | 123 | util_cache_command (&command_list, "set noasksub"); |
117 | util_cache_command (&command_list, "set subject=\"%s\"", arg); | 124 | args->send_mode = 1; |
118 | break; | 125 | break; |
119 | 126 | ||
120 | case 'u': | 127 | case 'u': |
... | @@ -143,6 +150,11 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -143,6 +150,11 @@ parse_opt (int key, char *arg, struct argp_state *state) |
143 | util_cache_command (&command_list, "set mode=send"); | 150 | util_cache_command (&command_list, "set mode=send"); |
144 | } | 151 | } |
145 | break; | 152 | break; |
153 | |||
154 | case ARGP_KEY_FINI: | ||
155 | if (args->send_mode) | ||
156 | util_cache_command (&command_list, "set mode=send"); | ||
157 | break; | ||
146 | 158 | ||
147 | default: | 159 | default: |
148 | return ARGP_ERR_UNKNOWN; | 160 | return ARGP_ERR_UNKNOWN; |
... | @@ -320,7 +332,8 @@ main (int argc, char **argv) | ... | @@ -320,7 +332,8 @@ main (int argc, char **argv) |
320 | args.args = NULL; | 332 | args.args = NULL; |
321 | args.file = NULL; | 333 | args.file = NULL; |
322 | args.user = NULL; | 334 | args.user = NULL; |
323 | 335 | args.send_mode = 0; | |
336 | |||
324 | /* argument parsing */ | 337 | /* argument parsing */ |
325 | 338 | ||
326 | mu_argp_init (program_version, NULL); | 339 | mu_argp_init (program_version, NULL); | ... | ... |
-
Please register or sign in to post a comment