| 18 | #include "xo_encoder.h" |
| 19 | |
| 20 | int |
| 21 | main (int argc, char **argv) |
| 22 | { |
| 23 | int i, count = 10; |
| 24 | int mon = 0; |
| 25 | xo_emit_flags_t flags = XOEF_RETAIN; |
| 26 | int opt_color = 1; |
| 27 | |
| 28 | xo_set_program("test_12"); |
| 29 | |
| 30 | argc = xo_parse_args(argc, argv); |
| 31 | if (argc < 0) |
| 32 | return 1; |
| 33 | |
| 34 | for (argc = 1; argv[argc]; argc++) { |
| 35 | if (xo_streq(argv[argc], "xml")) |
| 36 | xo_set_style(NULL, XO_STYLE_XML); |
| 37 | else if (xo_streq(argv[argc], "json")) |
| 38 | xo_set_style(NULL, XO_STYLE_JSON); |
| 39 | else if (xo_streq(argv[argc], "text")) |
| 40 | xo_set_style(NULL, XO_STYLE_TEXT); |
| 41 | else if (xo_streq(argv[argc], "html")) |
| 42 | xo_set_style(NULL, XO_STYLE_HTML); |
| 43 | else if (xo_streq(argv[argc], "no-color")) |
| 44 | opt_color = 0; |
| 45 | else if (xo_streq(argv[argc], "pretty")) |
| 46 | xo_set_flags(NULL, XOF_PRETTY); |
| 47 | else if (xo_streq(argv[argc], "xpath")) |
| 48 | xo_set_flags(NULL, XOF_XPATH); |
| 49 | else if (xo_streq(argv[argc], "info")) |
| 50 | xo_set_flags(NULL, XOF_INFO); |
| 51 | else if (xo_streq(argv[argc], "no-retain")) |
| 52 | flags &= ~XOEF_RETAIN; |
| 53 | else if (xo_streq(argv[argc], "big")) { |
| 54 | if (argv[argc + 1]) |
| 55 | count = atoi(argv[++argc]); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */ |
| 60 | if (opt_color) |
| 61 | xo_set_flags(NULL, XOF_COLOR); /* Force color output */ |
| 62 | xo_set_file(stdout); |
| 63 | |
| 64 | xo_open_container("top"); |
| 65 | xo_open_container("data"); |
| 66 | |
| 67 | xo_emit("{C:fg-red,bg-green}Merry XMas!!{C:}\n"); |
| 68 | |
| 69 | xo_emit("One {C:fg-yellow,bg-blue}{:animal}{C:}, " |
| 70 | "Two {C:fg-green,bg-yellow}{:animal}{C:}\n", |
| 71 | "fish", "fish"); |
| 72 | |
| 73 | const char *fmt1 = "The {C:fg-red}{k:name}{C:reset} is " |
| 74 | "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n"; |
| 75 | const char *fmt2 = "My {C:fg-red}{:hand}{C:reset} hand is " |
| 76 | "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n"; |
| 77 |
nothing calls this directly
no test coverage detected