PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/cli/test_cli_03.e

http://github.com/tybor/Liberty
Specman e | 46 lines | 34 code | 9 blank | 3 comment | 0 complexity | 77f95ce2b76057f60d894976b4413b3e MD5 | raw file
 1class TEST_CLI_03
 2
 3insert
 4   ARGUMENTS
 5   EIFFELTEST_TOOLS
 6   COMMAND_LINE_ARGUMENT_FACTORY
 7
 8create {}
 9   make
10
11feature {}
12   make
13      local
14         foo_option: COMMAND_LINE_TYPED_ARGUMENT[FIXED_STRING]
15         bar_option: COMMAND_LINE_TYPED_ARGUMENT[INTEGER]
16      do
17         foo_option := +option_string("f", "foo", "foo", "The foo string")   -- '+' prefix for a mandatory option
18         bar_option := -option_integer("b", "bar", "bar", "The bar integer") -- '-' prefix for an optional option (default)
19         create args.make(foo_option and bar_option)
20
21         -- an empty command line is not valid
22         setup
23         assert(not args.parse_command_line)
24
25         -- a bar option alone is not valid
26         setup
27         command_arguments.add_last("--bar=42")
28         assert(not args.parse_command_line)
29
30         -- must have at least foo, bar is optional
31         setup
32         command_arguments.add_last("--foo=the foo z'option")
33         command_arguments.add_last("--bar=42")
34         assert(args.parse_command_line)
35         assert(foo_option.item.is_equal("the foo z'option"))
36         assert(bar_option.item = 42)
37      end
38
39   setup
40      do
41         command_arguments.make(1)
42      end
43
44   args: COMMAND_LINE_ARGUMENTS
45
46end