1 #include "types.h"
2
3 #include "completion.h"
4
5 using std::string;
6
complete(Completion & complete,bool const * relativeTo)7 template<> void Converter<bool>::complete(Completion& complete, bool const* relativeTo)
8 {
9 complete.full({ "on", "off", "true", "false" });
10 if (relativeTo != nullptr) {
11 complete.full("toggle");
12 }
13 }
14
completeFull(Completion & complete,string s)15 void completeFull(Completion &complete, string s)
16 {
17 complete.full(s);
18 }
19
20 template<>
complete(Completion & complete,const Direction * relativeTo)21 void Converter<Direction>::complete(Completion& complete, const Direction* relativeTo)
22 {
23 complete.full({"up", "down", "left", "right"});
24 }
25
26 template<>
parse(const string & source)27 unsigned long Converter<unsigned long>::parse(const string& source)
28 {
29 long value = std::stol(source);
30 if (value < 0) {
31 throw std::invalid_argument("negative number is out of range");
32 } else {
33 return (unsigned long)(value);
34 }
35 }
36