Skip to content

Commit

Permalink
Commands: updated commands to allign with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdelahunt committed Jul 30, 2021
1 parent fdac945 commit 1958ba9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
4 changes: 3 additions & 1 deletion kasic/Commands/Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public Add() : base("add")
CommandSettings = new CommandSettings()
{
MinArgs = 2,
MaxArgs = 2,
MaxArgs = 4,
ArgumentList = new ArgumentList(new List<KasicType>()
{
KasicType.NUMBER,
KasicType.NUMBER,
KasicType.NUMBER,
KasicType.NUMBER
}),
Expand Down
41 changes: 39 additions & 2 deletions kasic/Commands/Divide.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
using System;
using System.Collections.Generic;
using kasic.Kasic;
using kasic.Logging;
using kasic.Utils;
using OperationResult;

namespace kasic.Commands
{
public class Divide
public class Divide : Command
{

public Divide() : base("div")
{
CommandSettings = new CommandSettings()
{
MinArgs = 2,
MaxArgs = 2,
ArgumentList = new ArgumentList(new List<KasicType>()
{
KasicType.NUMBER,
KasicType.NUMBER
}),
ReturnType = KasicType.NUMBER,
};
}

public override Result<IReturnObject, KasicError> Run(Context context, Arguments arguments, List<string> flags)
{
var firstNumber = arguments.AsNumber(context, 0);
if (firstNumber.IsError)
{
return Helpers.Error(firstNumber.Error);
}

var secondNumber = arguments.AsNumber(context, 1);
if (secondNumber.IsError)
{
return Helpers.Error(secondNumber.Error);
}

return new ReturnObject(this, firstNumber.Value / secondNumber.Value);
}
}
}
4 changes: 3 additions & 1 deletion kasic/Commands/Mult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public Mult() : base("mult")
CommandSettings = new CommandSettings()
{
MinArgs = 2,
MaxArgs = UInt32.MaxValue,
MaxArgs = 4,
ArgumentList = new ArgumentList(new List<KasicType>()
{
KasicType.NUMBER,
KasicType.NUMBER,
KasicType.NUMBER,
KasicType.NUMBER
}),
Expand Down

0 comments on commit 1958ba9

Please sign in to comment.