File tree 3 files changed +18
-5
lines changed
ydb/public/lib/ydb_cli/common
3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ class TCsvToYdbConverter {
186
186
break ;
187
187
}
188
188
case TTypeParser::ETypeKind::Pg: {
189
- if (token == NullValue) {
189
+ if (NullValue && token == NullValue) {
190
190
Builder.Pg (TPgValue (TPgValue::VK_NULL, {}, Parser.GetPg ()));
191
191
} else {
192
192
Builder.Pg (TPgValue (TPgValue::VK_TEXT, TString (token), Parser.GetPg ()));
@@ -250,6 +250,9 @@ class TCsvToYdbConverter {
250
250
}
251
251
252
252
void EnsureNull (TStringBuf token) const {
253
+ if (!NullValue) {
254
+ throw TMisuseException () << " Expected null value instead of \" " << token << " \" , but null value is not set." ;
255
+ }
253
256
if (token != NullValue) {
254
257
throw TMisuseException () << " Expected null value: \" " << NullValue << " \" , recieved: \" " << token << " \" ." ;
255
258
}
Original file line number Diff line number Diff line change @@ -24,23 +24,30 @@ void TProgressBar::AddProgress(size_t value) {
24
24
Render ();
25
25
}
26
26
27
+ TProgressBar::~TProgressBar () {
28
+ if (!Finished) {
29
+ Cout << Endl;
30
+ }
31
+ }
32
+
27
33
void TProgressBar::Render ()
28
34
{
29
35
std::optional<size_t > barLenOpt = GetTerminalWidth ();
30
36
if (!barLenOpt)
31
37
return ;
32
38
33
39
size_t barLen = *barLenOpt;
34
- TString output = ToString (CurProgress * 100 / Capacity);
40
+ TString output = " \r " ;
41
+ output += ToString (CurProgress * 100 / Capacity);
35
42
output += " % |" ;
36
43
TString outputEnd = " | [" ;
37
44
outputEnd += ToString (CurProgress);
38
45
outputEnd += " /" ;
39
46
outputEnd += ToString (Capacity);
40
47
outputEnd += " ]" ;
41
48
42
- if (barLen > output.Size ()) {
43
- barLen -= output.Size ();
49
+ if (barLen > output.Size () - 1 ) {
50
+ barLen -= output.Size () - 1 ;
44
51
} else {
45
52
barLen = 1 ;
46
53
}
@@ -55,10 +62,10 @@ void TProgressBar::Render()
55
62
output += TString (" █" ) * filledBarLen;
56
63
output += TString (" ░" ) * (barLen - filledBarLen);
57
64
output += outputEnd;
58
- output += " \r " ;
59
65
Cout << output;
60
66
if (CurProgress == Capacity) {
61
67
Cout << " \n " ;
68
+ Finished = true ;
62
69
}
63
70
Cout.Flush ();
64
71
}
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ class TProgressBar {
9
9
public:
10
10
explicit TProgressBar (size_t capacity);
11
11
12
+ ~TProgressBar ();
13
+
12
14
void SetProcess (size_t progress);
13
15
14
16
void AddProgress (size_t value);
@@ -18,6 +20,7 @@ class TProgressBar {
18
20
19
21
size_t Capacity = 0 ;
20
22
size_t CurProgress = 0 ;
23
+ bool Finished = false ;
21
24
};
22
25
23
26
} // namespace NConsoleClient
You can’t perform that action at this time.
0 commit comments