~mclehman/guestctl

ref: 850cd391f19f975f74610e658fa6f570916a2bae guestctl/lib/App/Guestctl/Common.pm6 -rw-r--r-- 1.1 KiB View raw
850cd391 — 0xFORDCOMMA Merge branch 'master' of github-0xford:0xFORDCOMMA/guestctl 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
unit module App::Guestctl::Common;

# Enum members are paired with their domain string representations.
# For GuestStatus, the string representations are used when status is output.
# For _____Command, the string representations are used to parse ______Action
# elements. These Action types are used to constrain command line arguments.
enum GuestStatus is export
    (Running => "up",
     Stopped => "down");

enum GuestCommand is export
    (Up        => "up",
     Down      => "down",
     Restart   => "restart",
     Status    => "status",
	 Commit    => "commit",
     Snapshots => "snapshots",
     Rollback  => "rollback",
     Connect   => "connect");

enum ManageCommand is export
    (Update  => "update",
     Sync    => "sync",
     Create  => "create");

enum RegisterCommand is export
    (Remote  => "remote",
     Host    => "host");

# I do not like this structure, but don't have a better option.
# Adding export declarations seriously harms readability.
subset GuestAction is export
    of Str where * eq any  GuestCommand::.values>>.Str;

subset ManageAction is export
    of Str where * eq any ManageCommand::.values>>.Str;