1 | #!/usr/bin/env python2
|
2 | """Flag parser defintions."""
|
3 |
|
4 | from __future__ import print_function
|
5 |
|
6 | from frontend import args
|
7 | from frontend.flag_spec import (FlagSpec, FlagSpecAndMore, _FlagSpecAndMore)
|
8 | from frontend import option_def
|
9 |
|
10 | #
|
11 | # Definitions for builtin_assign
|
12 | #
|
13 |
|
14 | EXPORT_SPEC = FlagSpec('export_')
|
15 | EXPORT_SPEC.ShortFlag('-n')
|
16 | EXPORT_SPEC.ShortFlag('-f') # stubbed
|
17 | EXPORT_SPEC.ShortFlag('-p')
|
18 |
|
19 | READONLY_SPEC = FlagSpec('readonly')
|
20 |
|
21 | # TODO: Check the consistency of -a and -A against values, here and below.
|
22 | READONLY_SPEC.ShortFlag('-a')
|
23 | READONLY_SPEC.ShortFlag('-A')
|
24 | READONLY_SPEC.ShortFlag('-p')
|
25 |
|
26 | NEW_VAR_SPEC = FlagSpec('new_var')
|
27 |
|
28 | # print stuff
|
29 | NEW_VAR_SPEC.ShortFlag('-f')
|
30 | NEW_VAR_SPEC.ShortFlag('-F')
|
31 | NEW_VAR_SPEC.ShortFlag('-p')
|
32 |
|
33 | NEW_VAR_SPEC.ShortFlag('-g') # Look up in global scope
|
34 |
|
35 | # Options +r +x +n
|
36 | NEW_VAR_SPEC.PlusFlag('x') # export
|
37 | NEW_VAR_SPEC.PlusFlag('r') # readonly
|
38 | NEW_VAR_SPEC.PlusFlag('n') # named ref
|
39 |
|
40 | # Common between readonly/declare
|
41 | NEW_VAR_SPEC.ShortFlag('-a')
|
42 | NEW_VAR_SPEC.ShortFlag('-A')
|
43 | NEW_VAR_SPEC.ShortFlag('-i') # no-op for integers
|
44 | NEW_VAR_SPEC.ShortFlag('-u') # no-op for case
|
45 | NEW_VAR_SPEC.ShortFlag('-l') # no-op for case
|
46 |
|
47 | UNSET_SPEC = FlagSpec('unset')
|
48 | UNSET_SPEC.ShortFlag('-v')
|
49 | UNSET_SPEC.ShortFlag('-f')
|
50 | #UNSET_SPEC.ShortFlag('-z', args.String)
|
51 |
|
52 | #
|
53 | # Definitions for builtin_meta
|
54 | #
|
55 |
|
56 | # Unused because there are no flags! Just --.
|
57 | EVAL_SPEC = FlagSpec('eval')
|
58 | SOURCE_SPEC = FlagSpec('source')
|
59 | SOURCE_SPEC.LongFlag('--builtin')
|
60 |
|
61 | COMMAND_SPEC = FlagSpec('command')
|
62 | COMMAND_SPEC.ShortFlag('-v')
|
63 | COMMAND_SPEC.ShortFlag('-V')
|
64 | COMMAND_SPEC.ShortFlag('-p')
|
65 |
|
66 | TYPE_SPEC = FlagSpec('type')
|
67 | TYPE_SPEC.ShortFlag('-f')
|
68 | TYPE_SPEC.ShortFlag('-t')
|
69 | TYPE_SPEC.ShortFlag('-p')
|
70 | TYPE_SPEC.ShortFlag('-P')
|
71 | TYPE_SPEC.ShortFlag('-a')
|
72 |
|
73 | #
|
74 | # Definitions for builtin_pure
|
75 | #
|
76 |
|
77 | ALIAS_SPEC = FlagSpec('alias') # no flags yet
|
78 | UNALIAS_SPEC = FlagSpec('unalias') # no flags yet
|
79 | UNALIAS_SPEC.ShortFlag('-a')
|
80 |
|
81 | SHOPT_SPEC = FlagSpec('shopt')
|
82 | SHOPT_SPEC.ShortFlag('-s', long_name='--set')
|
83 | SHOPT_SPEC.ShortFlag('-u', long_name='--unset')
|
84 | SHOPT_SPEC.ShortFlag('-o') # use 'set -o' names
|
85 | # TODO: --print could print in a verbose format. (Annoying: codegen conflicts
|
86 | # with Python keyword.)
|
87 | SHOPT_SPEC.ShortFlag('-p')
|
88 | SHOPT_SPEC.ShortFlag('-q') # query option settings
|
89 |
|
90 | HASH_SPEC = FlagSpec('hash')
|
91 | HASH_SPEC.ShortFlag('-r')
|
92 |
|
93 | ECHO_SPEC = FlagSpec('echo')
|
94 | ECHO_SPEC.ShortFlag('-e') # no backslash escapes
|
95 | ECHO_SPEC.ShortFlag('-n')
|
96 |
|
97 | #
|
98 | # osh/builtin_printf.py
|
99 | #
|
100 |
|
101 | PRINTF_SPEC = FlagSpec('printf')
|
102 | PRINTF_SPEC.ShortFlag('-v', args.String)
|
103 |
|
104 | #
|
105 | # osh/builtin_misc.py
|
106 | #
|
107 |
|
108 | READ_SPEC = FlagSpec('read')
|
109 | READ_SPEC.ShortFlag('-r')
|
110 | READ_SPEC.ShortFlag('-s') # silent
|
111 | READ_SPEC.ShortFlag('-u', args.Int) # file descriptor
|
112 | READ_SPEC.ShortFlag('-t', args.Float) # timeout
|
113 | READ_SPEC.ShortFlag('-n', args.Int)
|
114 | READ_SPEC.ShortFlag('-N', args.Int)
|
115 | READ_SPEC.ShortFlag('-a', args.String) # name of array to read into
|
116 | READ_SPEC.ShortFlag('-d', args.String)
|
117 | READ_SPEC.ShortFlag('-p', args.String) # prompt
|
118 |
|
119 | # OSH extension (not really considered YSH!)
|
120 | READ_SPEC.ShortFlag('-0') # until NUL, like IFS= read -r -d ''
|
121 | # Arguably it could be named like
|
122 | # grep --null -Z
|
123 | # xargs --null -0
|
124 | # But this format is NOT recommended in YSH! It's unbuffered and slow. We
|
125 | # prefer lines with escaping.
|
126 |
|
127 | READ_SPEC.LongFlag('--all')
|
128 | READ_SPEC.LongFlag('--raw-line')
|
129 | READ_SPEC.LongFlag('--num-bytes', args.Int)
|
130 | # don't strip the trailing newline
|
131 | READ_SPEC.LongFlag('--with-eol')
|
132 |
|
133 | MAPFILE_SPEC = FlagSpec('mapfile')
|
134 | MAPFILE_SPEC.ShortFlag('-t')
|
135 |
|
136 | CD_SPEC = FlagSpec('cd')
|
137 | CD_SPEC.ShortFlag('-L')
|
138 | CD_SPEC.ShortFlag('-P')
|
139 |
|
140 | PUSHD_SPEC = FlagSpec('pushd')
|
141 |
|
142 | POPD_SPEC = FlagSpec('popd')
|
143 |
|
144 | DIRS_SPEC = FlagSpec('dirs')
|
145 | DIRS_SPEC.ShortFlag('-c')
|
146 | DIRS_SPEC.ShortFlag('-l')
|
147 | DIRS_SPEC.ShortFlag('-p')
|
148 | DIRS_SPEC.ShortFlag('-v')
|
149 |
|
150 | PWD_SPEC = FlagSpec('pwd')
|
151 | PWD_SPEC.ShortFlag('-L')
|
152 | PWD_SPEC.ShortFlag('-P')
|
153 |
|
154 | HELP_SPEC = FlagSpec('help')
|
155 | #HELP_SPEC.ShortFlag('-i') # show index
|
156 | # Note: bash has help -d -m -s, which change the formatting
|
157 |
|
158 | HISTORY_SPEC = FlagSpec('history')
|
159 | HISTORY_SPEC.ShortFlag('-a')
|
160 | HISTORY_SPEC.ShortFlag('-r')
|
161 | HISTORY_SPEC.ShortFlag('-c')
|
162 | HISTORY_SPEC.ShortFlag('-d', args.Int)
|
163 |
|
164 | #
|
165 | # osh/builtin_process.py
|
166 | #
|
167 |
|
168 | EXEC_SPEC = FlagSpec('exec')
|
169 |
|
170 | WAIT_SPEC = FlagSpec('wait')
|
171 | WAIT_SPEC.ShortFlag('-n')
|
172 |
|
173 | TRAP_SPEC = FlagSpec('trap')
|
174 | TRAP_SPEC.ShortFlag('-p')
|
175 | TRAP_SPEC.ShortFlag('-l')
|
176 |
|
177 | JOB_SPEC = FlagSpec('jobs')
|
178 | JOB_SPEC.ShortFlag('-l', help='long format')
|
179 | JOB_SPEC.ShortFlag('-p', help='prints PID only')
|
180 | JOB_SPEC.LongFlag('--debug', help='display debug info')
|
181 |
|
182 | ULIMIT_SPEC = FlagSpec('ulimit')
|
183 |
|
184 | ULIMIT_SPEC.ShortFlag('-a', help='Print all limits')
|
185 | ULIMIT_SPEC.LongFlag('--all', help='Alias for -a')
|
186 | ULIMIT_SPEC.ShortFlag('-H', help='Use hard limit')
|
187 | ULIMIT_SPEC.ShortFlag('-S', help='Use soft limit')
|
188 |
|
189 | _ULIMIT_RESOURCES = [
|
190 | '-c',
|
191 | '-d',
|
192 | '-f',
|
193 | '-n',
|
194 | '-s',
|
195 | '-t',
|
196 | '-v',
|
197 | ]
|
198 |
|
199 | for u_flag in _ULIMIT_RESOURCES:
|
200 | ULIMIT_SPEC.ShortFlag(u_flag)
|
201 |
|
202 | #
|
203 | # FlagSpecAndMore
|
204 | #
|
205 |
|
206 | #
|
207 | # set and shopt
|
208 | #
|
209 |
|
210 |
|
211 | def _AddShellOptions(spec):
|
212 | # type: (_FlagSpecAndMore) -> None
|
213 | """Shared between 'set' builtin and the shell's own arg parser."""
|
214 | spec.InitOptions()
|
215 | spec.InitShopt()
|
216 |
|
217 | for opt in option_def.All():
|
218 | if opt.builtin == 'set':
|
219 | spec.Option(opt.short_flag, opt.name)
|
220 | # Notes:
|
221 | # - shopt option don't need to be registered; we validate elsewhere
|
222 | # - 'interactive' Has a cell for internal use, but isn't allowed to be
|
223 | # modified.
|
224 |
|
225 |
|
226 | MAIN_SPEC = FlagSpecAndMore('main')
|
227 |
|
228 | MAIN_SPEC.ShortFlag('-c', args.String,
|
229 | quit_parsing_flags=True) # command string
|
230 | MAIN_SPEC.LongFlag('--help')
|
231 | MAIN_SPEC.LongFlag('--version')
|
232 |
|
233 | # --tool ysh-ify, etc.
|
234 | # default is ''
|
235 | #
|
236 | # More ideas for tools
|
237 | # undefined-vars - a static analysis pass
|
238 | # parse-glob - to debug parsing
|
239 | # parse-printf
|
240 | MAIN_SPEC.LongFlag('--tool', [
|
241 | 'tokens', 'lossless-cat', 'syntax-tree', 'fmt', 'test', 'ysh-ify', 'deps',
|
242 | 'cat-em'
|
243 | ])
|
244 |
|
245 | MAIN_SPEC.ShortFlag('-i') # interactive
|
246 | MAIN_SPEC.ShortFlag('-l') # login - currently no-op
|
247 | MAIN_SPEC.LongFlag('--login') # login - currently no-op
|
248 | MAIN_SPEC.LongFlag('--headless') # accepts ECMD, etc.
|
249 |
|
250 | # TODO: -h too
|
251 | # the output format when passing -n
|
252 | MAIN_SPEC.LongFlag(
|
253 | '--ast-format',
|
254 | ['text', 'abbrev-text', 'html', 'abbrev-html', 'oheap', 'none'],
|
255 | default='abbrev-text')
|
256 |
|
257 | # Defines completion style.
|
258 | MAIN_SPEC.LongFlag('--completion-display', ['minimal', 'nice'], default='nice')
|
259 | # TODO: Add option for YSH prompt style? RHS prompt?
|
260 |
|
261 | MAIN_SPEC.LongFlag('--completion-demo')
|
262 |
|
263 | # Debugging feature only. $SH -n won't reparse a[x+1] and ``. Note that $SH
|
264 | # --tool automatically turns it on.
|
265 | MAIN_SPEC.LongFlag('--do-lossless')
|
266 |
|
267 | MAIN_SPEC.LongFlag('--print-status') # TODO: Replace with a shell hook
|
268 | MAIN_SPEC.LongFlag('--debug-file', args.String)
|
269 | MAIN_SPEC.LongFlag('--xtrace-to-debug-file')
|
270 |
|
271 | # This flag has is named like bash's equivalent. We got rid of --norc because
|
272 | # it can simply by --rcfile /dev/null.
|
273 | MAIN_SPEC.LongFlag('--rcfile', args.String)
|
274 | MAIN_SPEC.LongFlag('--rcdir', args.String)
|
275 | MAIN_SPEC.LongFlag('--norc')
|
276 |
|
277 | # e.g. to pass data on stdin but pretend that it came from a .hay file
|
278 | MAIN_SPEC.LongFlag('--location-str', args.String)
|
279 | MAIN_SPEC.LongFlag('--location-start-line', args.Int)
|
280 |
|
281 | _AddShellOptions(MAIN_SPEC)
|
282 |
|
283 | SET_SPEC = FlagSpecAndMore('set')
|
284 | _AddShellOptions(SET_SPEC)
|
285 |
|
286 | #
|
287 | # Types for completion
|
288 | #
|
289 |
|
290 |
|
291 | def _DefineCompletionFlags(spec):
|
292 | # type: (_FlagSpecAndMore) -> None
|
293 | spec.ShortFlag('-F', args.String, help='Complete with this function')
|
294 | spec.ShortFlag('-W', args.String, help='Complete with these words')
|
295 | spec.ShortFlag('-C',
|
296 | args.String,
|
297 | help='Complete with stdout lines of this command')
|
298 |
|
299 | spec.ShortFlag(
|
300 | '-P',
|
301 | args.String,
|
302 | help=
|
303 | 'Prefix is added at the beginning of each possible completion after '
|
304 | 'all other options have been applied.')
|
305 | spec.ShortFlag('-S',
|
306 | args.String,
|
307 | help='Suffix is appended to each possible completion after '
|
308 | 'all other options have been applied.')
|
309 | spec.ShortFlag('-X',
|
310 | args.String,
|
311 | help='''
|
312 | A glob pattern to further filter the matches. It is applied to the list of
|
313 | possible completions generated by the preceding options and arguments, and each
|
314 | completion matching filterpat is removed from the list. A leading ! in
|
315 | filterpat negates the pattern; in this case, any completion not matching
|
316 | filterpat is removed.
|
317 | ''')
|
318 |
|
319 |
|
320 | def _DefineCompletionOptions(spec):
|
321 | # type: (_FlagSpecAndMore) -> None
|
322 | """Common -o options for complete and compgen."""
|
323 | spec.InitOptions()
|
324 |
|
325 | # bashdefault, default, filenames, nospace are used in git
|
326 | spec.Option2('bashdefault',
|
327 | help='If nothing matches, perform default bash completions')
|
328 | spec.Option2(
|
329 | 'default',
|
330 | help="If nothing matches, use readline's default filename completion")
|
331 | spec.Option2(
|
332 | 'filenames',
|
333 | help="The completion function generates filenames and should be "
|
334 | "post-processed")
|
335 | spec.Option2('dirnames',
|
336 | help="If nothing matches, perform directory name completion")
|
337 | spec.Option2(
|
338 | 'nospace',
|
339 | help="Don't append a space to words completed at the end of the line")
|
340 | spec.Option2(
|
341 | 'plusdirs',
|
342 | help="After processing the compspec, attempt directory name completion "
|
343 | "and return those matches.")
|
344 |
|
345 |
|
346 | def _DefineCompletionActions(spec):
|
347 | # type: (_FlagSpecAndMore) -> None
|
348 | """Common -A actions for complete and compgen."""
|
349 |
|
350 | # NOTE: git-completion.bash uses -f and -v.
|
351 | # My ~/.bashrc on Ubuntu uses -d, -u, -j, -v, -a, -c, -b
|
352 | spec.InitActions()
|
353 | spec.Action('a', 'alias')
|
354 | spec.Action('b', 'binding')
|
355 | spec.Action('c', 'command')
|
356 | spec.Action('d', 'directory')
|
357 | spec.Action('e', 'export')
|
358 | spec.Action('f', 'file')
|
359 | spec.Action('k', 'keyword')
|
360 | spec.Action('j', 'job')
|
361 | spec.Action('u', 'user')
|
362 | spec.Action('v', 'variable')
|
363 | spec.Action(None, 'builtin')
|
364 | spec.Action(None, 'function')
|
365 | spec.Action(None, 'helptopic') # help
|
366 | spec.Action(None, 'setopt') # set -o
|
367 | spec.Action(None, 'shopt') # shopt -s
|
368 | spec.Action(None, 'signal') # kill -s
|
369 | spec.Action(None, 'stopped')
|
370 |
|
371 |
|
372 | COMPLETE_SPEC = FlagSpecAndMore('complete')
|
373 |
|
374 | _DefineCompletionFlags(COMPLETE_SPEC)
|
375 | _DefineCompletionOptions(COMPLETE_SPEC)
|
376 | _DefineCompletionActions(COMPLETE_SPEC)
|
377 |
|
378 | COMPLETE_SPEC.ShortFlag('-E', help='Define the compspec for an empty line')
|
379 | COMPLETE_SPEC.ShortFlag(
|
380 | '-D', help='Define the compspec that applies when nothing else matches')
|
381 |
|
382 | # I would like this to be less compatible
|
383 | # Field name conflicts with 'print' keyword
|
384 | #COMPLETE_SPEC.LongFlag(
|
385 | # '--print', help='Print spec')
|
386 |
|
387 | COMPGEN_SPEC = FlagSpecAndMore('compgen') # for -o and -A
|
388 |
|
389 | # TODO: Add -l for COMP_LINE. -p for COMP_POINT ?
|
390 | _DefineCompletionFlags(COMPGEN_SPEC)
|
391 | _DefineCompletionOptions(COMPGEN_SPEC)
|
392 | _DefineCompletionActions(COMPGEN_SPEC)
|
393 |
|
394 | COMPOPT_SPEC = FlagSpecAndMore('compopt') # for -o
|
395 | _DefineCompletionOptions(COMPOPT_SPEC)
|
396 |
|
397 | COMPADJUST_SPEC = FlagSpecAndMore('compadjust')
|
398 |
|
399 | COMPADJUST_SPEC.ShortFlag(
|
400 | '-n',
|
401 | args.String,
|
402 | help=
|
403 | 'Do NOT split by these characters. It omits them from COMP_WORDBREAKS.')
|
404 | COMPADJUST_SPEC.ShortFlag('-s',
|
405 | help='Treat --foo=bar and --foo bar the same way.')
|
406 |
|
407 | COMPEXPORT_SPEC = FlagSpecAndMore('compexport')
|
408 |
|
409 | COMPEXPORT_SPEC.ShortFlag('-c',
|
410 | args.String,
|
411 | help='Shell string to complete, like sh -c')
|
412 |
|
413 | COMPEXPORT_SPEC.LongFlag('--begin',
|
414 | args.Int,
|
415 | help='Simulate readline begin index into line buffer')
|
416 |
|
417 | COMPEXPORT_SPEC.LongFlag('--end',
|
418 | args.Int,
|
419 | help='Simulate readline end index into line buffer')
|
420 |
|
421 | # jlines is an array of strings with NO header line
|
422 | # TSV8 has a header line. It can have flag descriptions and other data.
|
423 | COMPEXPORT_SPEC.LongFlag('--format', ['jlines', 'tsv8'],
|
424 | default='jlines',
|
425 | help='Output format')
|
426 |
|
427 | #
|
428 | # Pure YSH
|
429 | #
|
430 |
|
431 | TRY_SPEC = FlagSpec('try_')
|
432 | TRY_SPEC.LongFlag('--assign',
|
433 | args.String,
|
434 | help='Assign status to this variable, and return 0')
|
435 |
|
436 | ERROR_SPEC = FlagSpec('error')
|
437 | FAILED_SPEC = FlagSpec('failed')
|
438 |
|
439 | BOOLSTATUS_SPEC = FlagSpec('boolstatus')
|
440 | ASSERT_SPEC = FlagSpec('assert')
|
441 |
|
442 | # Future directions:
|
443 | # run --builtin, run --command, run --proc:
|
444 | # to "replace" 'builtin' and # 'command'
|
445 |
|
446 | APPEND_SPEC = FlagSpec('append')
|
447 |
|
448 | SHVAR_SPEC = FlagSpec('shvar')
|
449 | #SHVAR_SPEC.Flag('-temp', args.String,
|
450 | # help='Push a NAME=val binding')
|
451 | #SHVAR_SPEC.Flag('-env', args.String,
|
452 | # help='Push a NAME=val binding and set the -x flag')
|
453 |
|
454 | CTX_SPEC = FlagSpec('ctx')
|
455 |
|
456 | PP_SPEC = FlagSpec('pp')
|
457 |
|
458 | # --verbose?
|
459 | FORK_SPEC = FlagSpec('fork')
|
460 | FORKWAIT_SPEC = FlagSpec('forkwait')
|
461 |
|
462 | # Might want --list at some point
|
463 | SOURCE_GUARD_SPEC = FlagSpec('source-guard')
|
464 | USE_SPEC = FlagSpec('use')
|
465 | USE_SPEC.LongFlag('--extern')
|
466 |
|
467 | RUNPROC_SPEC = FlagSpec('runproc')
|
468 | RUNPROC_SPEC.ShortFlag('-h', args.Bool, help='Show all procs')
|
469 |
|
470 | INVOKE_SPEC = FlagSpec('invoke')
|
471 | INVOKE_SPEC.LongFlag('--builtin') # like 'builtin'
|
472 | INVOKE_SPEC.LongFlag('--proc-like') # like 'runproc'
|
473 | INVOKE_SPEC.LongFlag('--extern') # like 'extern'
|
474 |
|
475 | EXTERN_SPEC = FlagSpec('extern')
|
476 |
|
477 | WRITE_SPEC = FlagSpec('write')
|
478 | WRITE_SPEC.LongFlag('--sep',
|
479 | args.String,
|
480 | default='\n',
|
481 | help='Characters to separate each argument')
|
482 | WRITE_SPEC.LongFlag('--end',
|
483 | args.String,
|
484 | default='\n',
|
485 | help='Characters to terminate the whole invocation')
|
486 | WRITE_SPEC.ShortFlag('-n',
|
487 | args.Bool,
|
488 | help="Omit newline (synonym for -end '')")
|
489 | # Do we need these two?
|
490 | WRITE_SPEC.LongFlag('--json',
|
491 | args.Bool,
|
492 | default=False,
|
493 | help='Write elements as JSON strings(lossy)')
|
494 | WRITE_SPEC.LongFlag('--j8',
|
495 | args.Bool,
|
496 | default=False,
|
497 | help='Write elements as J8 strings')
|
498 | # TODO: --jlines for conditional j"" prefix? Like maybe_shell_encode()
|
499 |
|
500 | # Legacy that's not really needed with J8 notation. The = operator might use a
|
501 | # separate pretty printer that shows \u{3bc}
|
502 | #
|
503 | # x means I want \x00
|
504 | # u means I want \u{1234}
|
505 | # raw is utf-8
|
506 | if 0:
|
507 | WRITE_SPEC.LongFlag(
|
508 | '--unicode', ['raw', 'u', 'x'],
|
509 | default='raw',
|
510 | help='Encode QSN with these options. '
|
511 | 'x assumes an opaque byte string, while raw and u try to '
|
512 | 'decode UTF-8.')
|
513 |
|
514 | PUSH_REGISTERS_SPEC = FlagSpec('push-registers')
|
515 |
|
516 | FOPEN_SPEC = FlagSpec('redir')
|
517 |
|
518 | #
|
519 | # JSON
|
520 | #
|
521 |
|
522 | JSON_WRITE_SPEC = FlagSpec('json_write')
|
523 |
|
524 | # TODO: --compact is probably better
|
525 | # --pretty=F is like JSON.stringify(d, null, 0)
|
526 | JSON_WRITE_SPEC.LongFlag('--pretty',
|
527 | args.Bool,
|
528 | default=True,
|
529 | help='Whitespace in output (default true)')
|
530 |
|
531 | # Unused:
|
532 | # JSON has the questionable decision of allowing (unpaired) surrogate like
|
533 | # \udc00.
|
534 | # When encoding, we try to catch the error on OUR side, rather than letting it
|
535 | # travel over the wire. But you can disable this.
|
536 | JSON_WRITE_SPEC.LongFlag(
|
537 | '--surrogate-ok',
|
538 | args.Bool,
|
539 | default=False,
|
540 | help='Invalid UTF-8 can be encoded as surrogate like \\udc00')
|
541 |
|
542 | JSON_WRITE_SPEC.LongFlag('--indent',
|
543 | args.Int,
|
544 | default=2,
|
545 | help='Indent JSON by this amount')
|
546 |
|
547 | JSON_READ_SPEC = FlagSpec('json_read')
|