-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commands: updated commands to allign with docs
- Loading branch information
1 parent
fdac945
commit 1958ba9
Showing
3 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters