| 22 | } |
| 23 | |
| 24 | void executeImpl(const CommandLineOptions & options, DisksClient & client) override |
| 25 | { |
| 26 | const auto & disk = client.getCurrentDiskWithPath(); |
| 27 | String path_from = disk.getRelativeFromRoot(getValueFromCommandLineOptionsThrow<String>(options, "path-from")); |
| 28 | std::optional<String> path_to = getValueFromCommandLineOptionsWithOptional<String>(options, "path-to"); |
| 29 | |
| 30 | auto in = disk.getDisk()->readFile(path_from, getReadSettings()); |
| 31 | std::unique_ptr<WriteBufferFromFileBase> out = {}; |
| 32 | if (path_to.has_value()) |
| 33 | { |
| 34 | String relative_path_to = disk.getRelativeFromRoot(path_to.value()); |
| 35 | out = disk.getDisk()->writeFile(relative_path_to); |
| 36 | LOG_INFO(log, "Writing file from '{}' to '{}' at disk '{}'", path_from, path_to.value(), disk.getDisk()->getName()); |
| 37 | copyData(*in, *out); |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | out = std::make_unique<WriteBufferFromFileDescriptor>(STDOUT_FILENO); |
| 42 | LOG_INFO(log, "Writing file from '{}' to 'stdout' at disk '{}'", path_from, disk.getDisk()->getName()); |
| 43 | copyData(*in, *out); |
| 44 | out->write('\n'); |
| 45 | } |
| 46 | out->finalize(); |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | CommandPtr makeCommandRead() |
nothing calls this directly
no test coverage detected