5
5
#include " cli/node/node.hpp"
6
6
7
7
namespace fc ::cli::_node {
8
+ using api::FileRef;
9
+ using api::ImportRes;
8
10
using api::RetrievalOrder;
9
11
using primitives::BigInt;
10
12
using primitives::address::Address;
@@ -17,12 +19,13 @@ namespace fc::cli::_node {
17
19
BigInt max_funds;
18
20
boost::filesystem::path path;
19
21
std::string provider;
22
+ bool car{};
20
23
21
24
CLI_OPTS () {
22
25
Opts opts;
23
26
auto option{opts.add_options ()};
24
27
option (" from" , po::value (&from), " transaction from" );
25
- option (" pieceCID " , po::value (&piece_cid), " cid of piece to retrieve" );
28
+ option (" piece-CID " , po::value (&piece_cid), " cid of piece to retrieve" );
26
29
option (
27
30
" maxPrice" ,
28
31
po::value (&max_funds),
@@ -33,6 +36,9 @@ namespace fc::cli::_node {
33
36
option (" provider" ,
34
37
po::value (&provider)->required (),
35
38
" specifies retrieval provider to perform a deal" );
39
+ option (" car" ,
40
+ po::bool_switch (&car),
41
+ " store result of retrieval deal to car file" );
36
42
return opts;
37
43
}
38
44
};
@@ -53,7 +59,65 @@ namespace fc::cli::_node {
53
59
" Invalid Client Address: " + args.from )
54
60
}
55
61
// TODO: continue function
62
+ // TODO: positional args
56
63
}
57
64
};
58
65
66
+ struct clientImportData {
67
+ struct Args {
68
+ bool car{};
69
+ std::string path;
70
+
71
+ CLI_OPTS () {
72
+ Opts opts;
73
+ auto option{opts.add_options ()};
74
+ option (" car" ,
75
+ po::bool_switch (&car),
76
+ " import from a car file instead of a regular file" );
77
+ option (" path,p" , po::value (&path), " path to import" );
78
+ return opts;
79
+ }
80
+ };
81
+
82
+ CLI_RUN () {
83
+ Node::Api api{argm};
84
+ FileRef file_ref{args.path , args.car };
85
+ CLI_TRY_TEXT (result, api._ ->ClientImport (file_ref), " Fail of data import" )
86
+ std::cout << " File Root CID: " << result.root .toString ().value () << " \n " ;
87
+ std::cout << " Data Import Success\n " ;
88
+ }
89
+ };
90
+
91
+
92
+ struct clientGenerateCar {
93
+ struct Args {
94
+ std::string in_path;
95
+ std::string out_path;
96
+ CLI_OPTS (){
97
+ Opts opts;
98
+ auto option{opts.add_options ()};
99
+ option (" input-path, inp" , po::value (&in_path), " specifies path to source file" );
100
+ option (" output-path, outp" , po::value (&in_path), " specifies path to generated file" );
101
+ }
102
+
103
+ CLI_RUN (){
104
+ std::cout<<" Does not supported yet\n " ;
105
+ }
106
+ };
107
+ };
108
+
109
+ struct clientLocal : Empty{
110
+ CLI_RUN (){
111
+ Node::Api api {argm};
112
+ CLI_TRY_TEXT (result, api._ ->ClientListImports (), " Fail of getting imports list" );
113
+ for (auto it = result.begin (); it != result.end (); it++){
114
+ std::cout<<" Root CID: " <<it->root .toString ().value ()<<" \n " ;
115
+ std::cout<<" Source: " <<it->source <<" \n " ;
116
+ std::cout<<" Path: " <<it->path <<" \n " ;
117
+ }
118
+ }
119
+ };
120
+
121
+
122
+
59
123
} // namespace fc::cli::_node
0 commit comments