Skip to content

Client command format guidlines

kdhageman edited this page Apr 17, 2019 · 5 revisions

This page shows the design principles for the cli command format and should therefore be read when implementing new features for the cli client.

Format

The following structure is used for ALL commands.

hkn <entity> <action> <args>

where hkn is the binary, entity refers to the entity type, action the action to and args the required and optional arguments for the entity and action pair. Note that the available actions are dependent on the selected entity, and the available arguments are dependent on the selected entity and action.

Entities

Examples of entities are as follows:

hkn user ...
hkn exercise ...
hkn event ...

Actions

Examples of actions are as follows:

hkn user create ...
hkn exercise reset ...
hkn event list ...
hkn group list ...

Arguments

The required and optional arguments vary per entity and action pair. However, use the following principles:

  1. When an identifier refers to the entity in the command, it must be a required argument. For illustration, the sql identifier refers to the exercise entity:
hkn exercise update sql
  1. When an identifier does not refer to the entity in the command, it need to be specified as a flag. In the following example, the sql exercise must be reset for group group1 from event event1. Note that this principle holds for both required and optional arguments.
hkn exercise reset sql -e event1 -g group1

Identifiers

We use the following identifiers

Entity Identifier
event Each event has a subdomain that is used to route traffic by Haaukins. This subdomain is used as an event's identifier.
exercise In the exercise definition file, each exercise has a tag list, and these tags can be used to identify exercises in the cli.
group A unique identifier will be generated for groups. In order to get a group's identifier, use a list command (see example below).

Examples

List all groups in the event ev1:

$ hkn group list -ev ev1
GROUP ID         NAME              EMAIL
f58a13m          BestTeam          kh@es.aau.dk
jg018do          WorstTeam         tkp@es.aau.dk

Create a new event called event1 with tag ev1

$ hkn event create event1 -t ev1

Reset the SQL injection exercise for group BestTeam in event ev1.

$ hkn exercise reset sql -e ev1 -g f58a13m
Resetting exercises..
Done!