2 * Copyright (c) 2014, Juniper Networks, Inc.
4 * This SOFTWARE is licensed under the LICENSE provided in the
5 * ../Copyright file. By downloading, installing, copying, or otherwise
6 * using the SOFTWARE, you agree to be bound by the terms of that
8 * Phil Shafer, July 2014
16 #include "xo_config.h"
20 main (int argc, char **argv)
24 xo_emit_flags_t flags = XOEF_RETAIN;
27 argc = xo_parse_args(argc, argv);
31 for (argc = 1; argv[argc]; argc++) {
32 if (strcmp(argv[argc], "xml") == 0)
33 xo_set_style(NULL, XO_STYLE_XML);
34 else if (strcmp(argv[argc], "json") == 0)
35 xo_set_style(NULL, XO_STYLE_JSON);
36 else if (strcmp(argv[argc], "text") == 0)
37 xo_set_style(NULL, XO_STYLE_TEXT);
38 else if (strcmp(argv[argc], "html") == 0)
39 xo_set_style(NULL, XO_STYLE_HTML);
40 else if (strcmp(argv[argc], "no-color") == 0)
42 else if (strcmp(argv[argc], "pretty") == 0)
43 xo_set_flags(NULL, XOF_PRETTY);
44 else if (strcmp(argv[argc], "xpath") == 0)
45 xo_set_flags(NULL, XOF_XPATH);
46 else if (strcmp(argv[argc], "info") == 0)
47 xo_set_flags(NULL, XOF_INFO);
48 else if (strcmp(argv[argc], "no-retain") == 0)
49 flags &= ~XOEF_RETAIN;
50 else if (strcmp(argv[argc], "big") == 0) {
52 count = atoi(argv[++argc]);
56 xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */
58 xo_set_flags(NULL, XOF_COLOR); /* Force color output */
61 xo_open_container("top");
62 xo_open_container("data");
64 xo_emit("{C:fg-red,bg-green}Merry XMas!!{C:}\n");
66 xo_emit("One {C:fg-yellow,bg-blue}{:animal}{C:}, "
67 "Two {C:fg-green,bg-yellow}{:animal}{C:}\n",
70 const char *fmt1 = "The {C:fg-red}{k:name}{C:reset} is "
71 "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n";
72 const char *fmt2 = "My {C:fg-red}{:hand}{C:reset} hand is "
73 "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n";
75 for (i = 0; i < count; i++) {
76 xo_open_instance("thing");
77 xo_emit_f(flags, fmt1, "thing", "green", "green", 2, 15);
78 xo_emit_f(flags, fmt2, "left", "blue", "blue", 3, 45);
81 xo_close_container("data");
82 xo_close_container_h(NULL, "top");