2 * Copyright (c) 2015, 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 2015
20 main (int argc, char **argv)
26 struct item list[] = {
37 argc = xo_parse_args(argc, argv);
41 for (argc = 1; argv[argc]; argc++) {
42 if (strcmp(argv[argc], "xml") == 0)
43 xo_set_style(NULL, XO_STYLE_XML);
44 else if (strcmp(argv[argc], "json") == 0)
45 xo_set_style(NULL, XO_STYLE_JSON);
46 else if (strcmp(argv[argc], "text") == 0)
47 xo_set_style(NULL, XO_STYLE_TEXT);
48 else if (strcmp(argv[argc], "html") == 0)
49 xo_set_style(NULL, XO_STYLE_HTML);
50 else if (strcmp(argv[argc], "pretty") == 0)
51 xo_set_flags(NULL, XOF_PRETTY);
52 else if (strcmp(argv[argc], "xpath") == 0)
53 xo_set_flags(NULL, XOF_XPATH);
54 else if (strcmp(argv[argc], "info") == 0)
55 xo_set_flags(NULL, XOF_INFO);
56 else if (strcmp(argv[argc], "error") == 0) {
58 xo_err(1, "error detected");
62 xo_set_flags(NULL, XOF_KEYS);
63 xo_set_program("test");
65 xo_open_container_h(NULL, "top");
67 xo_open_container("data");
68 xo_open_container("contents");
70 xo_emit("{T:Item/%-10s}{T:Count/%12s}\n");
72 for (ip = list; ip->i_title; ip++) {
73 xo_emit("Name: {l:name/%-10s/%s}\n", ip->i_title);
76 xo_close_container("contents");
79 xo_open_container("contents");
81 xo_emit("{T:Item/%-10s}{T:Count/%12s}\n");
83 for (ip = list; ip->i_title; ip++) {
84 xo_emit("Name: {l:item/%-10s/%s}\n", ip->i_title);
87 xo_close_container("contents");
91 xo_open_container("contents");
92 xo_emit("{T:Test/%-10s}{T:Three/%12s}\n");
95 for (ip = list; ip->i_title; ip++) {
96 xo_emit("Name: {l:item/%-10s/%s}\n", ip->i_title);
98 xo_emit("{Lwc:/Total:}{:total}\n", "six");
100 xo_emit("{:one}", "one");
101 xo_emit("{l:two}", "two");
102 xo_emit("{:three}", "three");
105 xo_close_container("contents");
109 xo_close_container_h(NULL, "top");