changing folder structure

This commit is contained in:
2023-08-10 16:01:39 -03:00
parent 73b0bac359
commit 3b2a4dc6d5
16 changed files with 19 additions and 16 deletions

View File

@@ -0,0 +1,45 @@
using Kasbot.Annotations;
namespace Kasbot.Models
{
public class Flags
{
[Flag("-s", "-silent")]
public bool Silent { get; set; }
[Flag("-r", "-repeat")]
public bool Repeat { get; set; }
public Flags() { }
public Flags(string command)
{
this.Parse(command);
}
public string Parse(string command)
{
string result = command;
this.GetType().GetProperties().ToList().ForEach(prop =>
{
Attribute.GetCustomAttributes(prop).ToList().ForEach(attr =>
{
if (attr is FlagAttribute flag)
{
flag.Names.ForEach(name =>
{
if (command.Contains(name))
{
prop.SetValue(this, true);
result = result.Replace(name, string.Empty);
}
});
}
});
});
return result;
}
}
}