ShareX/ShareX.HelpersLib/CLI/CLICommand.cs

66 lines
2.0 KiB
C#
Raw Normal View History

2013-11-03 12:53:49 +02:00
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
2025-01-08 03:46:27 +03:00
Copyright (c) 2007-2025 ShareX Team
2013-11-03 12:53:49 +02:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using System;
2014-12-10 22:25:20 +02:00
namespace ShareX.HelpersLib
2013-11-03 12:53:49 +02:00
{
public class CLICommand
{
public string Command { get; set; }
public string Parameter { get; set; }
2014-11-06 13:27:23 +02:00
public bool IsCommand { get; set; } // Starts with hyphen?
2013-11-03 12:53:49 +02:00
2014-11-06 13:27:23 +02:00
public CLICommand(string command = null, string parameter = null)
2013-11-03 12:53:49 +02:00
{
Command = command;
2014-11-06 13:27:23 +02:00
Parameter = parameter;
2013-11-03 12:53:49 +02:00
}
2014-11-06 14:40:42 +02:00
2022-10-15 01:46:28 +03:00
public bool CheckCommand(string command, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
{
2022-10-15 01:46:28 +03:00
return !string.IsNullOrEmpty(Command) && Command.Equals(command, comparisonType);
}
2014-11-06 14:40:42 +02:00
public override string ToString()
{
string text = "";
if (IsCommand)
{
text += "-";
}
text += Command;
2014-11-06 14:40:42 +02:00
if (!string.IsNullOrEmpty(Parameter))
{
text += " \"" + Parameter + "\"";
2014-11-06 14:40:42 +02:00
}
return text;
}
2013-11-03 12:53:49 +02:00
}
}