Commit ac0ddd0
authored
cli: support "-" and "@" for pipes and files (#365)
This PR adds support for flags to optionally allow the user to specify
special syntaxes that tell the CLI to read the contents from a pipe,
prompt, or file. This behavior is off by default and must be enabled on
a per-flag basis.
- If a flag sets `AllowFromFile` to true, then if the value for the flag
starts with an "@" symbol, the argument is interpreted as a filepath and
the contents are read from disk. This is theoretically possible today
with shellisms (e.g. `-foo=$(cat bar.txt)`), but this provides a
shell-agnostic implementation. If the file does not start with "@", then
the value is read as a string as normal. As a special case where the
user really wanted the value to be the literal "@", "\\@" can be used to
escape the input.
- If a flag sets `AllowFromPrompt` to true, then if the value for the
flag is exactly the string "-", then the flag expects input from stdin
or a tty. If neither are present, then the user is prompted. As a
special case where the user really wanted the literal value "-", "\\-"
can be used to escape the input.
Again, both of these behaviors are off by default and must be enabled on
a per-flag basis. In general, I don't expect many flags will use this
configuration, but it's useful to be consistent where necessary.
Finally, it looks like there are some new linting errors, since the
linter was failing locally for me, so I fixed those up.1 parent ea610d9 commit ac0ddd0
File tree
9 files changed
+614
-277
lines changed- cache
- cli
- githubauth
- multicloser
- serving
9 files changed
+614
-277
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
170 | 169 | | |
171 | 170 | | |
172 | 171 | | |
173 | | - | |
| 172 | + | |
174 | 173 | | |
175 | 174 | | |
176 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
267 | 274 | | |
268 | 275 | | |
269 | 276 | | |
| |||
483 | 490 | | |
484 | 491 | | |
485 | 492 | | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
| 493 | + | |
502 | 494 | | |
503 | 495 | | |
504 | 496 | | |
| |||
575 | 567 | | |
576 | 568 | | |
577 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
0 commit comments