bump 0.1.2.5
[htalkat.git] / Command.hs
blob52bd8315051a545a2de32783121e0944c0a031b6
1 -- This file is part of htalkat
2 -- Copyright (C) 2021 Martin Bays <mbays@sdf.org>
3 --
4 -- This program is free software: you can redistribute it and/or modify
5 -- it under the terms of version 3 of the GNU General Public License as
6 -- published by the Free Software Foundation, or any later version.
7 --
8 -- You should have received a copy of the GNU General Public License
9 -- along with this program. If not, see http://www.gnu.org/licenses/.
11 module Command where
13 import Data.Char (toLower)
14 import Data.List (isPrefixOf)
15 import Safe (headMay)
17 data Command
18 = Help
19 | Identity
20 | Name
21 | Answer
22 | Connect
23 | Listen
24 deriving (Eq,Ord,Show,Enum)
26 commands :: [Command]
27 commands = enumFrom Help
29 cmdOfStr :: String -> Maybe Command
30 cmdOfStr s = headMay [ c
31 | c <- commands
32 , s `isPrefixOf` (toLower <$> show c) ]