~ubuntu-branches/ubuntu/hardy/gengetopt/hardy

« back to all changes in this revision

Viewing changes to tests/test_no_handle_help.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-01-29 14:55:40 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080129145540-bkah1bl330gpelmh
Tags: 2.22-1ubuntu1
* Merge with Debian; remaining changes:
  - Fix build failures with g++-4.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* test_no_handle_help.c test */
 
2
 
 
3
/* test manual handling of help and version */
 
4
 
 
5
#include <stdlib.h>
 
6
#include <stdio.h>
 
7
 
 
8
#include "test_no_handle_help_cmd.h"
 
9
 
 
10
static struct gengetopt_args_info args_info;
 
11
 
 
12
int
 
13
main (int argc, char **argv)
 
14
{
 
15
  int result = 0;
 
16
  /* if --help is specified with other options, do not print
 
17
   the complete output of help, but only the description of that option */
 
18
  short help_printed = 0;
 
19
 
 
20
  if (test_no_handle_help_cmd_parser (argc, argv, &args_info) != 0) {
 
21
    result = 1;
 
22
    goto end;
 
23
  }
 
24
 
 
25
  printf("####################\n# HEADER\n####################\n");
 
26
 
 
27
  if (args_info.detailed_help_given)
 
28
    test_no_handle_help_cmd_parser_print_detailed_help();
 
29
 
 
30
  if (args_info.version_given)
 
31
    test_no_handle_help_cmd_parser_print_version();
 
32
 
 
33
  if (args_info.height_given) {
 
34
    printf ("specified --height %d\n", args_info.height_arg);
 
35
    if (args_info.help_given) {
 
36
      printf ("%s\n", args_info.height_help);
 
37
      help_printed = 1;
 
38
    }
 
39
  }
 
40
 
 
41
  if (args_info.vavoom_given) {
 
42
    printf ("specified --vavoom %s\n", args_info.vavoom_arg);
 
43
    if (args_info.help_given) {
 
44
      printf ("%s\n", args_info.vavoom_help);
 
45
      help_printed = 1;
 
46
    }
 
47
  }
 
48
 
 
49
  if (args_info.help_given && !help_printed)
 
50
    test_no_handle_help_cmd_parser_print_help();
 
51
 
 
52
  printf("####################\n# FOOTER\n####################\n");
 
53
 
 
54
 end:
 
55
  test_no_handle_help_cmd_parser_free (&args_info);
 
56
  return result;
 
57
}