# How to define a command?
PREREQUISITE
Open .kdomain file, first define a
command-set.For example to define a command
createlottery, first define a command-set with an appropriate name, using Lottery as the command set name here:command-set Lottery { ... }Now define the command inside the command-set.
command-set Lottery { command create{ ... } }Inside the command definition:
- specify the input (if any),
- define one or more pre-conditions(if any)
- specify the output (if any)
- define one or more post-condition (if any)
command-set Lottery { command create{ input(lotteryName:String,amount:Int) pre{ condition AmountMustBeGreaterThanZero => `input.amount>0` failing "Amount must be greater than 0" } output(result:String) post{ condition lotteryCreated => ... } } }In order to implement the command logic follow steps listed here.