Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
| 8 | #pragma once |
| 9 | |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 10 | #include <boost/mpl/vector.hpp> |
Václav Kubernát | 509ce65 | 2019-05-29 19:46:44 +0200 | [diff] [blame] | 11 | #include <boost/spirit/home/x3/support/ast/position_tagged.hpp> |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 12 | #include "ast_path.hpp" |
Václav Kubernát | 627f615 | 2018-08-29 13:23:56 +0200 | [diff] [blame] | 13 | #include "ast_values.hpp" |
Václav Kubernát | 6a7dd4d | 2020-06-23 22:44:13 +0200 | [diff] [blame] | 14 | #include "yang_operations.hpp" |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 15 | |
| 16 | namespace x3 = boost::spirit::x3; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 17 | |
Václav Kubernát | 7707cae | 2020-01-16 12:04:53 +0100 | [diff] [blame] | 18 | using keyValue_ = std::pair<std::string, leaf_data_>; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 19 | |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 20 | enum class LsOption { |
| 21 | Recursive |
| 22 | }; |
| 23 | |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 24 | struct discard_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 25 | static constexpr auto name = "discard"; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 26 | static constexpr auto shortHelp = "discard - Discard current changes."; |
| 27 | static constexpr auto longHelp = R"( |
| 28 | discard |
| 29 | |
| 30 | Discards current changes. Accepts no arguments. |
| 31 | |
| 32 | Usage: |
| 33 | /> discard)"; |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 34 | bool operator==(const discard_& b) const; |
| 35 | }; |
| 36 | |
Václav Kubernát | 11afac7 | 2018-07-18 14:59:53 +0200 | [diff] [blame] | 37 | struct ls_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 38 | static constexpr auto name = "ls"; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 39 | static constexpr auto shortHelp = "ls - List available nodes."; |
| 40 | static constexpr auto longHelp = R"( |
| 41 | ls [--recursive] [path] |
| 42 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 43 | Lists available child nodes in the current context node. Optionally accepts |
| 44 | a path argument. Accepts both schema paths and data paths. Path starting |
| 45 | with a forward slash means an absolute path. |
| 46 | |
| 47 | Options: |
| 48 | --recursive makes `ls` work recursively |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 49 | |
| 50 | Usage: |
| 51 | /> ls |
| 52 | /> ls --recursive module:node |
| 53 | /> ls /module:node)"; |
Václav Kubernát | 11afac7 | 2018-07-18 14:59:53 +0200 | [diff] [blame] | 54 | bool operator==(const ls_& b) const; |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 55 | std::vector<LsOption> m_options; |
Václav Kubernát | beaa8aa | 2020-04-29 22:39:34 +0200 | [diff] [blame] | 56 | boost::optional<boost::variant<dataPath_, schemaPath_, module_>> m_path; |
Václav Kubernát | 11afac7 | 2018-07-18 14:59:53 +0200 | [diff] [blame] | 57 | }; |
| 58 | |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 59 | struct cd_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 60 | static constexpr auto name = "cd"; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 61 | static constexpr auto shortHelp = "cd - Enter a different node."; |
| 62 | static constexpr auto longHelp = R"( |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 63 | cd <path> |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 64 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 65 | Changes context to a node specified by <path>. Only accepts data paths |
| 66 | (paths with all list keys supplied). |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 67 | |
| 68 | Usage: |
| 69 | /> cd /module:node/node2 |
| 70 | /> cd ..)"; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 71 | bool operator==(const cd_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 72 | dataPath_ m_path; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | struct create_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 76 | static constexpr auto name = "create"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 77 | static constexpr auto shortHelp = "create - Create a node."; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 78 | static constexpr auto longHelp = R"( |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 79 | create <path> |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 80 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 81 | Creates a node specified by <path>. |
| 82 | Supported node types are list items, leaflist instance and presence |
| 83 | containers. |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 84 | |
| 85 | Usage: |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 86 | /> create /module:pContainer |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 87 | /> create /module:leafList['value'] |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 88 | /> create /module:list[key=value][anotherKey=value])"; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 89 | bool operator==(const create_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 90 | dataPath_ m_path; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | struct delete_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 94 | static constexpr auto name = "delete"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 95 | static constexpr auto shortHelp = "delete - Delete a node."; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 96 | static constexpr auto longHelp = R"( |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 97 | delete <path> |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 98 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 99 | Deletes a node specified by <path>. |
| 100 | Supported node types are leafs, list items, leaflist instance and presence |
| 101 | containers. |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 102 | |
| 103 | Usage: |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 104 | /> delete /module:pContainer |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 105 | /> delete /module:leafList['value'] |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 106 | /> delete /module:list[key=value][anotherKey=value])"; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 107 | bool operator==(const delete_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 108 | dataPath_ m_path; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct set_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 112 | static constexpr auto name = "set"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 113 | static constexpr auto shortHelp = "set - Set value of a leaf."; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 114 | static constexpr auto longHelp = R"( |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 115 | set <path_to_leaf> <value> |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 116 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 117 | Sets the leaf specified by <path_to_leaf> to <value>. |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 118 | |
| 119 | Usage: |
| 120 | /> set /module:leaf 123 |
| 121 | /> set /module:leaf abc)"; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 122 | bool operator==(const set_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 123 | dataPath_ m_path; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 124 | leaf_data_ m_data; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 125 | }; |
| 126 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 127 | struct commit_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 128 | static constexpr auto name = "commit"; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 129 | static constexpr auto shortHelp = "commit - Commit current changes."; |
| 130 | static constexpr auto longHelp = R"( |
| 131 | commit |
| 132 | |
| 133 | Commits the current changes. Accepts no arguments. |
| 134 | |
| 135 | Usage: |
| 136 | /> commit)"; |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 137 | }; |
| 138 | |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 139 | struct get_ : x3::position_tagged { |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 140 | static constexpr auto name = "get"; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 141 | static constexpr auto shortHelp = "get - Retrieve configuration from the server."; |
| 142 | static constexpr auto longHelp = R"( |
| 143 | get [path] |
| 144 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 145 | Prints out content of the current datastore at a specified [path], or below |
| 146 | the current context tree. |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 147 | |
| 148 | Usage: |
| 149 | /> get |
| 150 | /> get /module:path)"; |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 151 | bool operator==(const get_& b) const; |
Václav Kubernát | 8f6bff3 | 2020-06-10 14:51:10 +0200 | [diff] [blame] | 152 | boost::optional<boost::variant<dataPath_, module_>> m_path; |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 153 | }; |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 154 | |
Václav Kubernát | 9cfcd87 | 2020-02-18 12:34:02 +0100 | [diff] [blame] | 155 | struct describe_ : x3::position_tagged { |
| 156 | static constexpr auto name = "describe"; |
| 157 | static constexpr auto shortHelp = "describe - Print information about YANG tree path."; |
| 158 | static constexpr auto longHelp = R"( |
| 159 | describe <path> |
| 160 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 161 | Shows documentation of YANG tree paths. In the YANG model, each item may |
Václav Kubernát | 9cfcd87 | 2020-02-18 12:34:02 +0100 | [diff] [blame] | 162 | have an optional `description` which often explains the function of that |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 163 | node to the end user. This command takes the description from the YANG model |
| 164 | and shows it to the user along with additional data, such as the type of the |
| 165 | node, units of leaf values, etc. |
Václav Kubernát | 9cfcd87 | 2020-02-18 12:34:02 +0100 | [diff] [blame] | 166 | |
| 167 | Usage: |
| 168 | /> describe /module:node)"; |
| 169 | bool operator==(const describe_& b) const; |
| 170 | |
| 171 | boost::variant<schemaPath_, dataPath_> m_path; |
| 172 | }; |
| 173 | |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 174 | struct copy_ : x3::position_tagged { |
| 175 | static constexpr auto name = "copy"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 176 | static constexpr auto shortHelp = "copy - Copy configuration."; |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 177 | static constexpr auto longHelp = R"( |
| 178 | copy <source> <destination> |
| 179 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 180 | Copies configuration from <source> to <destination>. |
| 181 | |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 182 | Usage: |
| 183 | /> copy running startup |
| 184 | /> copy startup running)"; |
| 185 | bool operator==(const copy_& b) const; |
| 186 | |
| 187 | Datastore m_source; |
| 188 | Datastore m_destination; |
| 189 | }; |
| 190 | |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 191 | enum class MoveMode { |
| 192 | Begin, |
| 193 | End, |
| 194 | Before, |
| 195 | After |
| 196 | }; |
| 197 | |
| 198 | struct move_ : x3::position_tagged { |
| 199 | static constexpr auto name = "move"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 200 | static constexpr auto shortHelp = "move - Move (leaf)list instances."; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 201 | static constexpr auto longHelp = R"( |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 202 | move <path> begin |
| 203 | move <path> end |
| 204 | move <path> before <key> |
| 205 | move <path> after <key> |
| 206 | |
| 207 | Moves the instance specified by <path> to the position specified by the |
| 208 | specified by the second and third argument. |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 209 | |
| 210 | Usage: |
| 211 | /> move mod:leaflist['abc'] begin |
| 212 | /> move mod:leaflist['def'] after 'abc' |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 213 | /> move mod:interfaces[name='eth0'] after [name='eth1'])"; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 214 | bool operator==(const move_& b) const; |
| 215 | |
| 216 | dataPath_ m_source; |
| 217 | |
| 218 | std::variant<yang::move::Absolute, yang::move::Relative> m_destination; |
| 219 | }; |
| 220 | |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 221 | struct dump_ : x3::position_tagged { |
| 222 | static constexpr auto name = "dump"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 223 | static constexpr auto shortHelp = "dump - Print out datastore content as JSON or XML."; |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 224 | static constexpr auto longHelp = R"( |
| 225 | dump xml|json |
| 226 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 227 | Prints out the content of the datastore. Supports JSON and XML. |
| 228 | |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 229 | Usage: |
| 230 | /> dump xml |
| 231 | /> dump json)"; |
| 232 | bool operator==(const dump_& other) const; |
| 233 | |
| 234 | DataFormat m_format; |
| 235 | }; |
| 236 | |
Václav Kubernát | aa4250a | 2020-07-22 00:02:23 +0200 | [diff] [blame] | 237 | struct prepare_ : x3::position_tagged { |
| 238 | static constexpr auto name = "prepare"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 239 | static constexpr auto shortHelp = "prepare - Initiate RPC/action."; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 240 | static constexpr auto longHelp = R"( |
Václav Kubernát | aa4250a | 2020-07-22 00:02:23 +0200 | [diff] [blame] | 241 | prepare <path-to-rpc-or-action> |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 242 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 243 | This command enters a mode for entering input parameters for the RPC/action. |
| 244 | In this mode, you can use commands like `set` on nodes inside the RPC/action |
| 245 | to set the input. After setting the input, use `exec` to execute the |
| 246 | RPC/action. |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 247 | |
| 248 | Usage: |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 249 | /> prepare /mod:launch-nukes |
| 250 | /> set kilotons 1000 |
| 251 | /> exec)"; |
Václav Kubernát | aa4250a | 2020-07-22 00:02:23 +0200 | [diff] [blame] | 252 | bool operator==(const prepare_& other) const; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 253 | |
| 254 | dataPath_ m_path; |
| 255 | }; |
| 256 | |
| 257 | struct exec_ : x3::position_tagged { |
| 258 | static constexpr auto name = "exec"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 259 | static constexpr auto shortHelp = "exec - Execute RPC/action."; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 260 | static constexpr auto longHelp = R"( |
Václav Kubernát | d8408e0 | 2020-12-02 05:13:27 +0100 | [diff] [blame] | 261 | exec [path] |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 262 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 263 | This command executes the RPC/action you have previously initiated via the |
| 264 | `prepare` command. |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 265 | |
Václav Kubernát | d8408e0 | 2020-12-02 05:13:27 +0100 | [diff] [blame] | 266 | If the RPC/action has no input parameters, it can be directly execute via |
| 267 | `exec` without usgin `prepare`. |
| 268 | |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 269 | Usage: |
Václav Kubernát | d8408e0 | 2020-12-02 05:13:27 +0100 | [diff] [blame] | 270 | /> exec |
| 271 | /> exec /mod:myRpc)"; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 272 | bool operator==(const exec_& other) const; |
Václav Kubernát | d8408e0 | 2020-12-02 05:13:27 +0100 | [diff] [blame] | 273 | |
| 274 | boost::optional<dataPath_> m_path; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | struct cancel_ : x3::position_tagged { |
| 278 | static constexpr auto name = "cancel"; |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 279 | static constexpr auto shortHelp = "cancel - Cancel an ongoing RPC/action input."; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 280 | static constexpr auto longHelp = R"( |
| 281 | cancel |
| 282 | |
Václav Kubernát | 419d917 | 2020-11-30 01:20:28 +0100 | [diff] [blame] | 283 | This command cancels a previously entered RPC/action context. |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 284 | |
| 285 | Usage: |
| 286 | /> cancel)"; |
| 287 | bool operator==(const cancel_& other) const; |
| 288 | }; |
| 289 | |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 290 | struct help_; |
Václav Kubernát | aa4250a | 2020-07-22 00:02:23 +0200 | [diff] [blame] | 291 | using CommandTypes = boost::mpl::vector<cancel_, cd_, commit_, copy_, create_, delete_, describe_, discard_, dump_, exec_, get_, help_, ls_, move_, prepare_, set_>; |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 292 | struct help_ : x3::position_tagged { |
| 293 | static constexpr auto name = "help"; |
| 294 | static constexpr auto shortHelp = "help - Print help for commands."; |
| 295 | static constexpr auto longHelp = R"( |
| 296 | help [command_name] |
| 297 | |
| 298 | Print help for command_name. If used without an argument, |
| 299 | print short help for all commands. |
| 300 | |
| 301 | Usage: |
| 302 | /> help |
| 303 | /> help cd |
| 304 | /> help help)"; |
| 305 | bool operator==(const help_& b) const; |
| 306 | |
| 307 | // The help command has got one optional argument – a command name (type). |
| 308 | // All commands are saved in CommandTypes, so we could just use that, but |
| 309 | // that way, Spirit would be default constructing the command structs, |
| 310 | // which is undesirable, so firstly we use mpl::transform to wrap |
| 311 | // CommandTypes with boost::type: |
| 312 | using WrappedCommandTypes = boost::mpl::transform<CommandTypes, boost::type<boost::mpl::_>>::type; |
| 313 | // Next, we create a variant over the wrapped types: |
| 314 | using CommandTypesVariant = boost::make_variant_over<WrappedCommandTypes>::type; |
| 315 | // Finally, we wrap the variant with boost::optional: |
| 316 | boost::optional<CommandTypesVariant> m_cmd; |
| 317 | }; |
| 318 | |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 319 | // TODO: The usage of MPL won't be necessary after std::variant support is added to Spirit |
| 320 | // https://github.com/boostorg/spirit/issues/270 |
Václav Kubernát | 5727242 | 2019-02-08 12:48:24 +0100 | [diff] [blame] | 321 | using command_ = boost::make_variant_over<CommandTypes>::type; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 322 | |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 323 | BOOST_FUSION_ADAPT_STRUCT(ls_, m_options, m_path) |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 324 | BOOST_FUSION_ADAPT_STRUCT(cd_, m_path) |
| 325 | BOOST_FUSION_ADAPT_STRUCT(create_, m_path) |
| 326 | BOOST_FUSION_ADAPT_STRUCT(delete_, m_path) |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 327 | BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data) |
Václav Kubernát | ab53899 | 2019-03-06 15:30:50 +0100 | [diff] [blame] | 328 | BOOST_FUSION_ADAPT_STRUCT(enum_, m_value) |
Václav Kubernát | dab73ca | 2020-10-26 23:44:43 +0100 | [diff] [blame] | 329 | BOOST_FUSION_ADAPT_STRUCT(bits_, m_bits) |
Václav Kubernát | ab53899 | 2019-03-06 15:30:50 +0100 | [diff] [blame] | 330 | BOOST_FUSION_ADAPT_STRUCT(binary_, m_value) |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 331 | BOOST_FUSION_ADAPT_STRUCT(identityRef_, m_prefix, m_value) |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 332 | BOOST_FUSION_ADAPT_STRUCT(commit_) |
Václav Kubernát | 9cfcd87 | 2020-02-18 12:34:02 +0100 | [diff] [blame] | 333 | BOOST_FUSION_ADAPT_STRUCT(describe_, m_path) |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 334 | BOOST_FUSION_ADAPT_STRUCT(help_, m_cmd) |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 335 | BOOST_FUSION_ADAPT_STRUCT(discard_) |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 336 | BOOST_FUSION_ADAPT_STRUCT(get_, m_path) |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 337 | BOOST_FUSION_ADAPT_STRUCT(copy_, m_source, m_destination) |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 338 | BOOST_FUSION_ADAPT_STRUCT(move_, m_source, m_destination) |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 339 | BOOST_FUSION_ADAPT_STRUCT(dump_, m_format) |
Václav Kubernát | aa4250a | 2020-07-22 00:02:23 +0200 | [diff] [blame] | 340 | BOOST_FUSION_ADAPT_STRUCT(prepare_, m_path) |
Václav Kubernát | d8408e0 | 2020-12-02 05:13:27 +0100 | [diff] [blame] | 341 | BOOST_FUSION_ADAPT_STRUCT(exec_, m_path) |