|
4 | 4 | #pragma once
|
5 | 5 | #include "cli/node/node.hpp"
|
6 | 6 |
|
7 |
| -namespace fc::cli::_node{ |
8 |
| - |
9 |
| - |
10 |
| - struct clientRetrive{ |
11 |
| - struct Args{ |
12 |
| - bool car{}; |
13 |
| - bool export_merkle_root{}; |
14 |
| - std::string data_selector; |
15 |
| - |
16 |
| - CLI_OPTS(){ |
17 |
| - Opts opts; |
| 7 | +namespace fc::cli::_node { |
| 8 | + using api::RetrievalOrder; |
| 9 | + using primitives::BigInt; |
| 10 | + using primitives::address::Address; |
| 11 | + using primitives::address::decodeFromString; |
| 12 | + |
| 13 | + struct clientRetrieve { |
| 14 | + struct Args { |
| 15 | + std::string from; |
| 16 | + std::string piece_cid; |
| 17 | + BigInt max_funds; |
| 18 | + boost::filesystem::path path; |
| 19 | + std::string provider; |
| 20 | + |
| 21 | + CLI_OPTS() { |
| 22 | + Opts opts; |
18 | 23 | auto option{opts.add_options()};
|
19 |
| - option("car", po::bool_switch(&car), "Export to a car file instead of a regular file"); |
20 |
| - option("data-selector", po::value(&data_selector), "IPLD datamodel text-path selector, or IPLD json selector"); |
21 |
| - option("car-export-merkle-proof", po::bool_switch(&export_merkle_root), "(requires --data-selector and --car) Export data-selector merkle proof"); |
| 24 | + option("from", po::value(&from), "transaction from"); |
| 25 | + option("pieceCID", po::value(&piece_cid), "cid of piece to retrieve"); |
| 26 | + option( |
| 27 | + "maxPrice", |
| 28 | + po::value(&max_funds), |
| 29 | + "specifies the maximum token amount that client ready to spend"); |
| 30 | + option("path", |
| 31 | + po::value(&path)->required(), |
| 32 | + "specifies the path to retrieve"); |
| 33 | + option("provider", |
| 34 | + po::value(&provider)->required(), |
| 35 | + "specifies retrieval provider to perform a deal"); |
22 | 36 | return opts;
|
23 | 37 | }
|
24 | 38 | };
|
25 | 39 |
|
26 |
| - |
27 |
| - CLI_RUN(){ |
28 |
| - std::cout<<args.data_selector<<"\n"; |
| 40 | + CLI_RUN() { |
| 41 | + Node::Api api{argm}; |
| 42 | + CLI_TRY_TEXT(cid, |
| 43 | + CID::fromString(args.piece_cid), |
| 44 | + "Invalid piece CID: " + args.piece_cid) |
| 45 | + if (!args.provider.empty()) { |
| 46 | + CLI_TRY_TEXT(miner, |
| 47 | + decodeFromString(args.provider), |
| 48 | + "Invalid Provider Address: " + args.provider) |
| 49 | + } |
| 50 | + if (!args.from.empty()) { |
| 51 | + CLI_TRY_TEXT(client, |
| 52 | + decodeFromString(args.from), |
| 53 | + "Invalid Client Address: " + args.from) |
| 54 | + } |
| 55 | + // TODO: continue function |
29 | 56 | }
|
30 | 57 | };
|
31 | 58 |
|
32 |
| - |
33 |
| - |
34 |
| - |
35 |
| - |
36 |
| -} //fc::cli::node |
| 59 | +} // namespace fc::cli::_node |
0 commit comments