File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
src/Flucli/Utils/Extensions Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
3
using System . Security ;
4
+ using System . Text ;
4
5
5
6
namespace Flucli . Utils . Extensions ;
6
7
@@ -9,7 +10,7 @@ public static class ArgumentExtension
9
10
public static IEnumerable < string > ToArguments ( this string cli )
10
11
{
11
12
List < string > args = [ ] ;
12
- string currentArg = string . Empty ;
13
+ StringBuilder currentArg = new ( ) ;
13
14
bool inQuotes = false ;
14
15
15
16
for ( int i = 0 ; i < cli . Length ; i ++ )
@@ -19,24 +20,25 @@ public static IEnumerable<string> ToArguments(this string cli)
19
20
if ( c == '"' )
20
21
{
21
22
inQuotes = ! inQuotes ;
23
+ currentArg . Append ( c ) ;
22
24
}
23
25
else if ( c == ' ' && ! inQuotes )
24
26
{
25
- if ( currentArg != string . Empty )
27
+ if ( currentArg . Length > 0 )
26
28
{
27
- args . Add ( currentArg ) ;
28
- currentArg = string . Empty ;
29
+ args . Add ( currentArg . ToString ( ) ) ;
30
+ currentArg . Clear ( ) ;
29
31
}
30
32
}
31
33
else
32
34
{
33
- currentArg += c ;
35
+ currentArg . Append ( c ) ;
34
36
}
35
37
}
36
38
37
- if ( currentArg != string . Empty )
39
+ if ( currentArg . Length > 0 )
38
40
{
39
- args . Add ( currentArg ) ;
41
+ args . Add ( currentArg . ToString ( ) ) ;
40
42
}
41
43
42
44
return args ;
You can’t perform that action at this time.
0 commit comments