Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/DieTime/cli-autocomplete

Cross-platform flexible autocomplete library for your cli applications.
https://github.com/DieTime/cli-autocomplete

autocomplete autocompletion cli cli-applications console cross-platform crossplatform hint library prompt terminal

Last synced: about 2 months ago
JSON representation

Cross-platform flexible autocomplete library for your cli applications.

Awesome Lists containing this project

README

        


logo



version

### About
Cross-platform flexible autocomplete library for your CLI applications

preview gif

### Features
- Cross-platform: `MacOS`, `Linux`, `Windows`
- Write your own autocomplete rules
- Setup your own highlight colors
- `single header` version of the library
- `static` and `dynamic` versions of the library

### Config Example
1. After `git` may follow: `config`, `init`, `clone`
2. After `config` may follow: `--global`, `user.name`, `user.email`
3. After `--global` may follow: `user.name`, `user.email`
4. After `user.name` may follow optional value: `"[name]"`
5. `...`
```
git
config
--global
user.name
"[name]"
user.email
"[email]"
user.name
"[name]"
user.email
"[email]"
init
[repository_name]
clone
[url]
```

### Simple Example
> More complex example with: `color settings`, `handling optional values` and `line title configuration` [you will find here](examples/custom_input.c)
```cpp
#include

#include "../include/autocomplete.h"

int main() {
// Parsing the configuration file
Tree* rules = tree_create("../example.config");

fprintf(
stderr,
"Attention! Please run the executable file only\n"
" through the command line!\n\n"

"- To switch the prompts press UP or DOWN arrow.\n"
"- To move cursor press LEFT or RIGHT arrow.\n"
"- To edit input press DELETE or BACKSPACE key.\n"
"- To apply current prompt press TAB key.\n\n"
);

// Listening process
while (1) {
// Get user input
char* str = input(rules);
printf("\n%s\n", str);

// Stop listening if user need
if (strcmp(str, "") == 0) {
free(str);
break;
}

// Free user input string
free(str);
}

// Free rules
tree_free(rules);

return 0;
}
```

### How to start
```bash
git clone https://github.com/DieTime/CLI-AutoComplete.git
cd CLI-AutoComplete/

cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./cmake-build
cmake --build ./cmake-build --config Release

----------------------- RUN EXAMPLE ---------------------

# Unix
cd builds/examples/unix/Release
./custom_example

# MinGW
cd builds/examples/mingw/Release
custom_example.exe

# MSVC
cd builds/examples/msvc/Release
custom_example.exe
```

### Linking a shared library [[Releases]](https://github.com/DieTime/CLI-Autocomplete/releases/tag/v2.0.0-shared)

##### Unix
```bash
gcc -o -L -I -lcliac -Wl,-rpath,
```

##### Windows MSVC from VS Command Prompt
```cmd
cl /EHsc /Fe.exe /I /link
```

##### Windows MinGW
```cmd
gcc -o .exe -L -I -lcliac
```

### Linking a static library [[Releases]](https://github.com/DieTime/CLI-Autocomplete/releases/tag/v2.0.0-static)

##### Unix
```bash
gcc -o -L -I -lcliac
```

##### Windows MSVC from VS Command Prompt
```cmd
cl /EHsc /Fe.exe /I /link
```

##### Windows MinGW
```cmd
gcc -o .exe -L -I -lcliac
```

### About changes
> A detailed description of the changes can be found in [CHANGELOG.md](CHANGELOG.md)

### Support the author
You can support me so that there will be more good open source projects in the future



Buy Me A Coffee