Skip to content

Commit 933dc62

Browse files
Console Project. In the end
1 parent ea0a318 commit 933dc62

10 files changed

Lines changed: 297 additions & 92 deletions

β€ŽConsoleProject/Command.csβ€Ž

Lines changed: 0 additions & 15 deletions
This file was deleted.

β€ŽConsoleProject/ConsoleCommand.csβ€Ž

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace ConsoleProject
55
{
66
public class ConsoleCommand
77
{
8-
private Command _command;
9-
private List<string> _attributes;
8+
/*private Command _command;
9+
private List<string> _attributes;*/
1010

11-
public Command Command
11+
/*public Command Command
1212
{
1313
get => _command;
1414
set => _command = value;
@@ -22,9 +22,9 @@ public List<string> GetAttributes()
2222
public ConsoleCommand()
2323
{
2424
_attributes = new List<string>();
25-
}
25+
}*/
2626

27-
private string GetAddress(string str)
27+
/*private string GetAddress(string str)
2828
{
2929
try
3030
{
@@ -38,11 +38,11 @@ private string GetAddress(string str)
3838
}
3939
4040
return null;
41-
}
41+
}*/
4242

43-
public void Parse(string str)
43+
public List<string> Parse(string str)
4444
{
45-
try
45+
/*try
4646
{
4747
int pos = str.IndexOf(' ');
4848
string command = String.Empty;
@@ -64,21 +64,59 @@ public void Parse(string str)
6464
}
6565
else
6666
{
67-
Console.WriteLine("We are here.");
6867
if (str == Command.dir.ToString() || str == Command.cls.ToString() ||
69-
str == Command.help.ToString())
68+
str == Command.help.ToString() || str == Command.exit.ToString())
7069
command = str;
7170
_command = (Command) Enum.Parse(typeof(Command), command);
7271
}
7372
}
7473
catch (Exception e)
74+
{
75+
Console.WriteLine(e.Message);
76+
}*/
77+
78+
try
79+
{
80+
List<string> list = new List<string>();
81+
int pos = str.IndexOf(" ");
82+
list.Add(str.Substring(0, pos));
83+
84+
while (pos < str.Length - 1)
85+
{
86+
while (str[++pos] == ' ');
87+
88+
bool f = true;
89+
int endPos = pos;
90+
91+
for (int i = pos; i < str.Length; i++)
92+
{
93+
if (str[i] == '\"')
94+
{
95+
f = !f;
96+
}
97+
98+
if (f && (str[i] == ' ' || i == str.Length - 1))
99+
{
100+
endPos = i;
101+
break;
102+
}
103+
}
104+
105+
list.Add(str.Substring(pos, endPos - pos + 1));
106+
pos = endPos;
107+
}
108+
109+
return list;
110+
}
111+
catch (Exception e)
75112
{
76113
Console.WriteLine(e.Message);
77114
}
78-
115+
116+
return null;
79117
}
80118

81-
private bool IsCorrect(string command)
119+
/*private bool IsCorrect(string command)
82120
{
83121
foreach (var c in Enum.GetNames(typeof(Command)))
84122
{
@@ -88,7 +126,6 @@ private bool IsCorrect(string command)
88126
}
89127
}
90128
return false;
91-
}
92-
129+
}*/
93130
}
94131
}

0 commit comments

Comments
 (0)