47 lines
743 B
C#
47 lines
743 B
C#
|
|
using System;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using TermApp.Core;
|
||
|
|
|
||
|
|
|
||
|
|
namespace TermApp.Commands
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
public class AddCommand : ICommand
|
||
|
|
{
|
||
|
|
public string Name => "add";
|
||
|
|
public string Description => "Adds two integers together args : a + b";
|
||
|
|
|
||
|
|
public void Execute(string[] args, string input = null)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (args.Length < 1)
|
||
|
|
{
|
||
|
|
|
||
|
|
Console.WriteLine(Description);
|
||
|
|
return;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
if (int.TryParse(args[0], out int a) && int.TryParse(args[1], out int b))
|
||
|
|
{
|
||
|
|
|
||
|
|
int result = a + b;
|
||
|
|
Console.WriteLine(result);
|
||
|
|
return;
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
|
||
|
|
Console.WriteLine("Make sure Both Args are integers!");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|