Commit Graph

23 Commits

Author SHA1 Message Date
antichris 4a17a04514
complete: enable complete.Complete() output capturing (#138)
* complete: test capturing Complete() output

Implement an Example test to demonstrate capturing the output
of Complete(), which is crucial for integration tests.

* complete: do not hard-code the I/O streams at the package initialization

Instead of defining the input/output streams as unexported global vars
that only get their values assigned to once, at the very initialization
of the package, use the values that `os.Stdin` and `os.Stdout` have at
the particular moment on every `complete.Complete()` call.

Fix #137

* complete: capture and discard output in TestComplete

Restore earlier behavior using proper stream redirection this time.

* complete: output capturing example: define things in the package scope

Define the `stringLookup` func type and `promptEnv` func in the package
scope instead of the `ExampleComplete_outputCapturing` test.

* complete: rename the `stringLookup` func type to `getEnvFn`
2021-04-06 06:46:20 +03:00
Chris Walz 246bd25c47
fix crash when COMP_POINT is greater than COMP_LINE size (#128)
Some shells (inexplicably) occasionally have a COMP_POINT that is greater than the COMP_LINE size. When that happens completion should be based on length of the COMP_LINE to avoid an out of bounds error.

See the original hack fix here: https://github.com/chriswalz/bit/blob/master/cmd/bitcomplete.go on line 39
2020-11-08 18:56:26 +02:00
Eyal Posener cf002b9a50 Fix completion of help when completing flags 2019-11-21 00:16:33 +02:00
Eyal Posener c3bfbddfe6 Move install package back to project root 2019-11-19 05:17:52 +02:00
Eyal Posener 7c7ab2f59a update module import path 2019-11-18 01:25:16 +02:00
Eyal Posener 8724aaf183 V2 2019-11-18 01:05:47 +02:00
Eyal Posener 29f43e246e deprecate match package 2019-07-05 17:29:25 +03:00
Eyal Posener d258bec9b1 use goreadme 2019-03-07 06:59:58 +02:00
Eyal Posener be2a7ff220 protect line slicing from index out of range 2018-10-25 19:38:01 +03:00
Eyal Posener 5fdb1adfd7 Add support for CMP_POINT
Fixes #72
2018-10-19 20:10:37 +03:00
Eyal Posener a1f9ea005b
Merge branch 'master' into split-last-equal 2017-11-04 11:52:49 +02:00
Eyal Posener aae7e1e39f Add logic to complete when last flag uses the equal sign
If the last flag is of the form -flag=value, complete the value according to -flag.
2017-11-04 11:32:33 +02:00
Eyal Posener 7ee9623f2b Filter matches as a final stage
This simplifies the prediction logic writing, the predictor
doesn't need to filter our according to line matching, instead
it returns everything and the filtering is done at the end.

This does not break current behavior.
2017-11-04 10:51:40 +02:00
Eyal Posener 1a4c871bd8 Fix installation
Fixes #36
2017-05-23 07:33:14 +03:00
Eyal Posener 967bae76f3 Add Predictor interface 2017-05-11 20:33:29 +03:00
Eyal Posener a28594d28e Add args struct 2017-05-11 18:50:12 +03:00
Eyal Posener 72dfe017e9 Improve files and directories completion 2017-05-11 02:16:39 +03:00
Eyal Posener 9de57bdcf5 Enable completion and executable be the same command
Fixes #6
2017-05-10 19:21:35 +03:00
Eyal Posener d33bac720b Remove Complete struct 2017-05-06 09:27:51 +03:00
Eyal Posener 1af7c0b3b7 Roughly add all go commands 2017-05-06 00:25:27 +03:00
Eyal Posener 04d16f6064 Renamings 2017-05-05 22:15:23 +03:00
Eyal Posener 5e07cbd4c2 Add file completion flag 2017-05-05 21:57:21 +03:00
Eyal Posener 04e78e42ab Initial commit 2017-05-05 18:01:08 +03:00