-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.go
205 lines (186 loc) · 4.52 KB
/
commands.go
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// -----------------------------------------------------------------------------
// CMDX Utilities Suite cmdx/[commands.go]
// (c) balarabe@protonmail.com License: GPLv3
// -----------------------------------------------------------------------------
package main
// Command _ _
type Command struct {
ShortName string
FullName string
ShortInfo string
FullInfo string
Category int
Handler func(cmd Command, args []string)
}
// Interactive Commands:
// blocks
const (
// BB is the Begin Block command.
BB = "BB"
// BC is the Blocks Copy command. (same as CB)
BC = "BC"
// BE is the Block End command (same as EB)
BE = "BE"
// CB is the Copy Blocks command (same as BC)
CB = "CB"
// CLL copies all extra-long lines in source
CLL = "CLL"
// EB is the End Block (same as BE) command
EB = "EB"
// FF is the Find in Files command
FF = "FF"
// ID is the ID (insert) command
ID = "ID"
// UUID is the UUID (insert) command
UUID = "UUID"
// LT is the Less-Than sign (command applies to same line)
LT = "<"
// T timestamp (insert)
T = "T"
// XE is the Remove Error markers
XE = "XE"
)
const Margin = " " // 18 spaces
// AllCategories _ _
var AllCategories = map[int]string{
1: "File Manipulation",
2: "Text Manipulation",
3: "Time Logging",
4: "Other",
}
// AllCommands _ _
// The commands are grouped by category
var AllCommands = []Command{
// File Manipulation:
{
ShortName: "dd",
FullName: "del-dup",
ShortInfo: "Delete identical files: read <source>, delete in <target>",
Handler: deleteIdenticalFiles,
Category: 1,
},
{
ShortName: "ld",
FullName: "list-dup",
ShortInfo: "List identical files: read <source>, list in <target>",
Handler: listIdenticalFiles,
Category: 1,
},
{
ShortName: "rd",
FullName: "ren-dup",
ShortInfo: "Rename identical files: read <source>, rename in <target>",
Handler: renameIdenticalFiles,
Category: 1,
},
{
ShortName: "rh",
FullName: "ren-hash",
ShortInfo: "Renames files by prefixing their name with a hash",
Handler: renameFilesByHash,
Category: 1,
},
// Text Manipulation:
{
ShortName: "fw",
FullName: "file-words",
ShortInfo: "Lists all words with alphanumeric characters from <file>",
Handler: wordsInFile,
Category: 2,
},
{
ShortName: "me",
FullName: "mark-errors",
ShortInfo: "Insert build errors as comments in source code files",
Handler: markErrorsInSource, // uses 'flag' module to read arguments
Category: 2,
},
{
ShortName: "pb",
FullName: "part-backup",
ShortInfo: "Continuously back-up .part files streamed in current folder",
Handler: partBackup,
Category: 2,
},
{
ShortName: "rdf",
FullName: "repl-diffs",
ShortInfo: "Replace diffs in file(s). Requires <command-file>",
Handler: replaceDiffsInFiles,
Category: 2,
},
{
ShortName: "rl",
FullName: "rep-lines",
ShortInfo: "Replace lines in file(s). Requires <command-file>",
Handler: replaceLinesInFiles,
Category: 2,
},
{
ShortName: "rs",
FullName: "replace-strings",
ShortInfo: "Replace strings in file(s). Requires <command-file>",
Handler: replaceStringsInFiles,
Category: 2,
},
{
ShortName: "sf",
FullName: "sort-file",
ShortInfo: "Sorts all the lines in a file",
Handler: sortFileLines,
Category: 2,
},
// Time Logging:
{
ShortName: "lt",
FullName: "log-time",
ShortInfo: "Logs timestamps of changed files to autotime.txt",
Handler: logTime,
Category: 3,
},
{
ShortName: "mt",
FullName: "mark-time",
ShortInfo: "Change timestamps in source files. Requires path",
Handler: markTimeInFiles,
Category: 3,
},
{
ShortName: "now",
FullName: "time-now",
ShortInfo: "Displays current date/time in yyyy-mm-dd hh:nn:ss format",
Handler: timeNow,
Category: 3,
},
{
ShortName: "rt",
FullName: "rep-time",
ShortInfo: "Replace time entries. requires <source-file> <target-file>",
Handler: replaceTime,
Category: 3,
},
{
ShortName: "tr",
FullName: "time-report",
ShortInfo: "Summarizes time from log files.\n" +
Margin + "tr <date1> <date2> \"=<contains>\"... <source-file>",
Handler: timeReport,
Category: 3,
},
// Other:
{
ShortName: "uuid",
FullName: "print-uuid",
ShortInfo: "Generates and prints one or more UUIDs",
Handler: printUUID,
Category: 4,
},
{
ShortName: "mw",
FullName: "match-words",
ShortInfo: "Lists all words that use all the specified letters.",
Handler: matchWords,
Category: 4,
},
}
// end