-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsort.ts
223 lines (222 loc) · 5.83 KB
/
sort.ts
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
const completionSpec: Fig.Spec = {
name: "sort",
description: "Sort or merge records (lines) of text and binary files",
args: {
name: "file",
isVariadic: true,
template: "filepaths",
},
options: [
{
name: "--help",
description: "Shows help message",
},
{
name: "--version",
description: "Displays the current version of sort",
},
{
name: ["-c", "--check", "-C"],
args: {
name: "output",
isOptional: true,
suggestions: ["silent", "quiet"],
description: "Suppress errors on false check",
},
description: "Check that the single input file is sorted",
},
{
name: ["-m", "--merge"],
description:
"Merge only. The input files are assumed to be pre-sorted. If they are not sorted the output order is undefined",
},
{
name: ["-o", "--output"],
description:
"Print the output to the output file instead of the standard output",
args: {
name: "output",
},
},
{
name: ["-S", "--buffer-size"],
description: "Use size for the maximum size of the memory buffer",
args: {
name: "size",
},
},
{
name: ["-T", "--temporary-directory"],
description: "Store temporary files in the directory dir",
args: {
name: "dir",
template: "folders",
},
},
{
name: ["-u", "--unique"],
description:
"Unique keys. Suppress all lines that have a key that is equal to an already processed one",
},
{
name: "-s",
description:
"Stable sort. This option maintains the original record order of records that have an equal key",
},
{
name: ["-b", "--ignore-leading-blanks"],
description: "Ignore leading blank characters when comparing lines",
},
{
name: ["-d", "--dictionary-order"],
description:
"Consider only blank spaces and alphanumeric characters in comparisons",
},
{
name: ["-f", "--ignore-case"],
description:
"Convert all lowercase characters to their upper case equivalent before comparison",
},
{
name: ["-g", "--general-numeric-sort"],
description: "Sort by general numerical value",
},
{
name: ["-h", "--human-numeric-sort"],
description:
"Sort by numerical value, but take into account the SI suffix, if present",
},
{
name: ["-i", "--ignore-nonprinting"],
description: "Ignore all non-printable characters",
},
{
name: ["-M", "--month-sort"],
description:
"Sort by month abbreviations. Unknown strings are considered smaller than the month names",
},
{
name: ["-n", "--numeric-sort"],
description: "Sort fields numerically by arithmetic value",
},
{
name: ["-R", "--random-sort"],
description: "Sort by a random order",
},
{
name: ["-r", "--reverse"],
description: "Sort in reverse order",
},
{
name: ["-V", "--version-sort"],
description: "Sort version numbers",
},
{
name: ["-k", "--key"],
args: [
{
name: "field1",
},
{
name: "field2",
isOptional: true,
},
],
description:
"Define a restricted sort key that has the starting position field1, and optional ending position field2",
},
{
name: ["-t", "--field-separator"],
args: {
name: "char",
},
description: "Use char as a field separator character",
},
{
name: ["-z", "--zero-terminated"],
description: "Use NUL as record separator",
},
{
name: "--batch-size",
args: {
name: "num",
},
description:
"Specify maximum number of files that can be opened by sort at once",
},
{
name: "--compress-program",
args: {
name: "PROGRAM",
template: "filepaths",
},
description: "Use PROGRAM to compress temporary files (eg. bzip2)",
},
{
name: "--random-source",
args: {
name: "filename",
template: "filepaths",
},
description:
"In random sort, the file content is used as the source of the 'seed' data for the hash function choice",
},
{
name: "--debug",
description:
"Print some extra information about the sorting process to the standard output",
},
{
name: "--parallel",
description:
"Set the maximum number of execution threads. Default number equals to the number of CPUs",
},
{
name: "--files0-from",
args: {
name: "filename",
template: "filepaths",
},
description: "Take the input file list from the file filename",
},
{
name: "--radixsort",
description: "Try to use radix sort, if the sort specifications allow",
},
{
name: "--mergesort",
description:
"Use mergesort. This is a universal algorithm that can always be used, but it is not always the fastest",
},
{
name: "--qsort",
description:
"Try to use quick sort, if the sort specifications allow. This sort algorithm cannot be used with -u and -s",
},
{
name: "--heapsort",
description:
"Try to use heap sort, if the sort specifications allow. This sort algorithm cannot be used with -u and -s",
},
{
name: "--mmap",
description:
"Try to use file memory mapping system call. It may increase speed in some cases",
},
{
name: "--sort",
args: {
name: "type",
suggestions: [
"general-numeric",
"human-numeric",
"month",
"numeric",
"random",
],
},
description: "Select how to sort values",
},
],
};
export default completionSpec;