# How to define a command?


  1. Open .kdomain file, first define a command-set.

    For example to define a command create lottery, first define a command-set with an appropriate name, using Lottery as the command set name here:

    command-set Lottery { ... }
    
  2. Now define the command inside the command-set.


     




    command-set Lottery {
    	command create{ 
    		... 
    	}
    }
    
  3. 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 => ...
          }
        }
    }
    
  4. In order to implement the command logic follow steps listed here.