-
Notifications
You must be signed in to change notification settings - Fork 8
/
commands.c
97 lines (91 loc) · 2.15 KB
/
commands.c
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Copyright (C) 2014 Bert Vermeulen <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "tokenline.h"
#include "commands.h"
t_token_dict dict[] = {
{ /* Dummy entry */ },
{ T_SHOW, "show" },
{ T_SET, "set" },
{ T_HARDWARE, "hardware" },
{ T_VERSION, "version" },
{ T_DEVICE, "device" },
{ T_DIRECTORY, "directory" },
{ T_HELP, "help" },
{ T_CPU, "cpu" },
{ T_MEMORY, "memory" },
{ T_FREQUENCY, "frequency" },
{ T_MKDIR, "mkdir" },
{ T_LS, "ls" },
{ T_TAP, "tap" },
{ T_EXIT, "exit" },
{ }
};
t_token tokens_mode_device[] = {
{ T_SHOW,
.help = "Show device information" },
{ T_MKDIR,
.help = "Create directory" },
{ T_LS,
.help = "List files and directories" },
{ T_EXIT,
.help = "Exit device mode" },
{ }
};
t_token tokens_set[] = {
{ T_FREQUENCY,
.arg_type = T_ARG_FREQ,
.help = "Frequency" },
{ }
};
t_token tokens_hardware[] = {
{ T_CPU,
.help = "CPU" },
{ T_MEMORY,
.help = "Memory" },
{ }
};
t_token tokens_show[] = {
{ T_HARDWARE,
.subtokens = tokens_hardware,
.help = "Hardware information" },
{ T_VERSION,
.help = "Version" },
{ T_DEVICE,
.arg_type = T_ARG_INT,
.help = "Device" },
{ T_DIRECTORY,
.arg_type = T_ARG_STRING,
.help = "Directory" },
{ }
};
t_token tokens[] = {
{ T_SHOW,
.subtokens = tokens_show,
.help = "Show information" },
{ T_SET,
.subtokens = tokens_set,
.help = "Set things" },
{ T_DEVICE,
.help = "Device mode" },
{ T_TAP,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Tap" },
{ T_HELP,
.arg_type = T_ARG_HELP,
.help = "Available commands" },
{ }
};