Esempio n. 1
0
 def test_help(self):
     self.assertEqual(
         cli.parse_args(["-h"]),
         cli.CommandLine(action=cli.print_help),
     )
     self.assertEqual(
         cli.parse_args(["--help"]),
         cli.CommandLine(action=cli.print_help),
     )
Esempio n. 2
0
 def test_argument_with_missing_argument(self):
     self.assertEqual(
         cli.parse_args(["-I"]),
         cli.CommandLine(
             action=cli.print_help,
             failure="-I expects an argument",
         ),
     )
Esempio n. 3
0
 def test_unknown_arguments_causes_print_help(self):
     self.assertEqual(
         cli.parse_args(["-I", "stuff/include", "--foobar"]),
         cli.CommandLine(
             action=cli.print_help,
             failure="Unknown argument --foobar",
         ),
     )
Esempio n. 4
0
 def test_run_repl(self):
     self.assertEqual(
         cli.parse_args([]),
         cli.CommandLine(
             action=cli.run_repl,
             cycy=CyCy(parser=IncrementalParser()),
         ),
     )
Esempio n. 5
0
 def test_run_source_files(self):
     self.assertEqual(
         cli.parse_args(["-I", "a/include", "-I", "b/include", "file.c"]),
         cli.CommandLine(
             action=cli.run_source,
             source_files=["file.c"],
             cycy=CyCy(parser=IncrementalParser(parser=Parser(
                 preprocessor=preprocessor.with_directories(
                     ["a/include", "b/include"], ), ), ), ),
         ),
     )
Esempio n. 6
0
 def test_run_source_string(self):
     self.assertEqual(
         cli.parse_args(["-I", "a/include", "-c", "int main (void) {}"]),
         cli.CommandLine(
             action=cli.run_source,
             source_string="int main (void) {}",
             cycy=CyCy(parser=IncrementalParser(parser=Parser(
                 preprocessor=preprocessor.with_directories(
                     ["a/include"], ), ), ), ),
         ),
     )
Esempio n. 7
0
 def test_version(self):
     self.assertEqual(
         cli.parse_args(["--version"]),
         cli.CommandLine(action=cli.print_version),
     )
Esempio n. 8
0
def main(argv):
    command_line = parse_args(argv[1:])
    exit_status = command_line.action(command_line)
    return exit_status