Commit Graph

29 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 f929a1cfb4 Add github actions 2020-04-09 21:31:51 +03:00
Eyal Posener cf002b9a50 Fix completion of help when completing flags 2019-11-21 00:16:33 +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 e24ae2ec88 reproduce sub command bug 2019-10-23 22:27:02 +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
Alex Dadgar 2b9ace50d6 Fix tests from rebase 2017-08-24 17:37:26 -07:00
Alex Dadgar 97340ccc21 Default to hiding flags that start with hyphen unless last arg has a hyphen 2017-08-24 17:35:36 -07:00
Alex Dadgar 59e6151c5b Allow restricting completion of flags
This PR allows a command to specify that flags should only be completed
when a prefix is present. The motivation behind this is to have the
initial complation to prefer displaying argument completions and only
display flag completions when the user enters "hyphen <tab>".
2017-08-24 17:35:36 -07:00
Alex Dadgar d3c10410d6 Fix a subcommand matching
This PR fixes an issue where a subcommand matches the current set of
commands being examined. Fixes issue
https://github.com/posener/complete/issues/46
2017-08-23 13:58:31 -07:00
Eyal Posener 61d9904ba1 Fix './' prefix for file completion 2017-05-18 23:29:55 +03:00
Eyal Posener 096b79324e Add global flags for command
Fixes #24
2017-05-15 19:32:59 +03:00
Eyal Posener bc5d682221 fix nested files 2017-05-13 00:40:26 +03:00
Eyal Posener d6cbc0e969 predict: when searching for files, show also directories 2017-05-11 21:57:44 +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 5dbf53eec0 nicer signature for PredictSet 2017-05-06 00:53:03 +03:00
Eyal Posener c8263230e1 Add additional args
add predition of directories
add ability for prediction union
2017-05-05 23:07:18 +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