| 122 | } |
| 123 | |
| 124 | bool HandleGetCommand(std::vector<std::string> const& args, |
| 125 | cmExecutionStatus& status) |
| 126 | { |
| 127 | static std::map<cm::string_view, |
| 128 | std::function<cmCMakePath(cmCMakePath const&, bool)>> const |
| 129 | actions{ { "ROOT_NAME"_s, |
| 130 | [](cmCMakePath const& path, bool) -> cmCMakePath { |
| 131 | return path.GetRootName(); |
| 132 | } }, |
| 133 | { "ROOT_DIRECTORY"_s, |
| 134 | [](cmCMakePath const& path, bool) -> cmCMakePath { |
| 135 | return path.GetRootDirectory(); |
| 136 | } }, |
| 137 | { "ROOT_PATH"_s, |
| 138 | [](cmCMakePath const& path, bool) -> cmCMakePath { |
| 139 | return path.GetRootPath(); |
| 140 | } }, |
| 141 | { "FILENAME"_s, |
| 142 | [](cmCMakePath const& path, bool) -> cmCMakePath { |
| 143 | return path.GetFileName(); |
| 144 | } }, |
| 145 | { "EXTENSION"_s, |
| 146 | [](cmCMakePath const& path, bool last_only) -> cmCMakePath { |
| 147 | if (last_only) { |
| 148 | return path.GetExtension(); |
| 149 | } |
| 150 | return path.GetWideExtension(); |
| 151 | } }, |
| 152 | { "STEM"_s, |
| 153 | [](cmCMakePath const& path, bool last_only) -> cmCMakePath { |
| 154 | if (last_only) { |
| 155 | return path.GetStem(); |
| 156 | } |
| 157 | return path.GetNarrowStem(); |
| 158 | } }, |
| 159 | { "RELATIVE_PART"_s, |
| 160 | [](cmCMakePath const& path, bool) -> cmCMakePath { |
| 161 | return path.GetRelativePath(); |
| 162 | } }, |
| 163 | { "PARENT_PATH"_s, |
| 164 | [](cmCMakePath const& path, bool) -> cmCMakePath { |
| 165 | return path.GetParentPath(); |
| 166 | } } }; |
| 167 | |
| 168 | if (args.size() < 4) { |
| 169 | status.SetError("GET must be called with at least three arguments."); |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | auto const& action = args[2]; |
| 174 | |
| 175 | if (actions.find(action) == actions.end()) { |
| 176 | status.SetError( |
| 177 | cmStrCat("GET called with an unknown action: ", action, '.')); |
| 178 | return false; |
| 179 | } |
| 180 | |
| 181 | struct Arguments |
nothing calls this directly
no test coverage detected
searching dependent graphs…