26
26
#include "credential.h"
27
27
#include "exec_cmd.h"
28
28
#include "run-command.h"
29
+ #include "parse-options.h"
29
30
#ifdef NO_OPENSSL
30
31
typedef void * SSL ;
31
32
#endif
32
33
33
- static const char imap_send_usage [] = "git imap-send < <mbox>" ;
34
+ static int verbosity ;
35
+
36
+ static const char * const imap_send_usage [] = { "git imap-send [-v] [-q] < <mbox>" , NULL };
37
+
38
+ static struct option imap_send_options [] = {
39
+ OPT__VERBOSITY (& verbosity ),
40
+ OPT_END ()
41
+ };
34
42
35
43
#undef DRV_OK
36
44
#define DRV_OK 0
37
45
#define DRV_MSG_BAD -1
38
46
#define DRV_BOX_BAD -2
39
47
#define DRV_STORE_BAD -3
40
48
41
- static int Verbose , Quiet ;
42
-
43
49
__attribute__((format (printf , 1 , 2 )))
44
50
static void imap_info (const char * , ...);
45
51
__attribute__((format (printf , 1 , 2 )))
@@ -418,7 +424,7 @@ static int buffer_gets(struct imap_buffer *b, char **s)
418
424
if (b -> buf [b -> offset + 1 ] == '\n' ) {
419
425
b -> buf [b -> offset ] = 0 ; /* terminate the string */
420
426
b -> offset += 2 ; /* next line */
421
- if (Verbose )
427
+ if (0 < verbosity )
422
428
puts (* s );
423
429
return 0 ;
424
430
}
@@ -433,7 +439,7 @@ static void imap_info(const char *msg, ...)
433
439
{
434
440
va_list va ;
435
441
436
- if (! Quiet ) {
442
+ if (0 <= verbosity ) {
437
443
va_start (va , msg );
438
444
vprintf (msg , va );
439
445
va_end (va );
@@ -445,7 +451,7 @@ static void imap_warn(const char *msg, ...)
445
451
{
446
452
va_list va ;
447
453
448
- if (Quiet < 2 ) {
454
+ if (-2 < verbosity ) {
449
455
va_start (va , msg );
450
456
vfprintf (stderr , msg , va );
451
457
va_end (va );
@@ -522,7 +528,7 @@ static struct imap_cmd *issue_imap_cmd(struct imap_store *ctx,
522
528
cmd -> tag , cmd -> cmd , cmd -> cb .dlen ,
523
529
CAP (LITERALPLUS ) ? "+" : "" );
524
530
525
- if (Verbose ) {
531
+ if (0 < verbosity ) {
526
532
if (imap -> num_in_progress )
527
533
printf ("(%d in progress) " , imap -> num_in_progress );
528
534
if (!starts_with (cmd -> cmd , "LOGIN" ))
@@ -1352,12 +1358,14 @@ int main(int argc, char **argv)
1352
1358
1353
1359
git_setup_gettext ();
1354
1360
1355
- if (argc != 1 )
1356
- usage (imap_send_usage );
1357
-
1358
1361
setup_git_directory_gently (& nongit_ok );
1359
1362
git_imap_config ();
1360
1363
1364
+ argc = parse_options (argc , (const char * * )argv , "" , imap_send_options , imap_send_usage , 0 );
1365
+
1366
+ if (argc )
1367
+ usage_with_options (imap_send_usage , imap_send_options );
1368
+
1361
1369
if (!server .port )
1362
1370
server .port = server .use_ssl ? 993 : 143 ;
1363
1371
0 commit comments