Cross-platform flexible autocomplete library for your CLI applications
- Cross-platform:
macOS
,Linux
,Windows
- Write your own autocomplete rules
- Setup your own highlight colors
- Required
C++17
single header
version of the librarystatic
anddynamic
versions of the library
- After
git
may follow:config
,init
,clone
- After
config
may follow:--global
,user.name
,user.email
- After
--global
may follow:user.name
,user.email
- After
user.name
may follow optional value:"[name]"
...
git
config
--global
user.name
"[name]"
user.email
"[email]"
user.name
"[name]"
user.email
"[email]"
init
[repository name]
clone
[url]
More complex example with:
color settings
,handling optional values
andline title configuration
you will find here
#include <iostream>
#include <string>
#include "../include/autocomplete.h"
int main() {
std::string config_file_path = "../config.txt";
auto [dict, status, message] = parse_config_file(config_file_path);
if (status) {
while (true) {
std::cerr << "Attention! Please run the executable file only" << std::endl
<< "through the command line!\n\n";
std::cerr << "- To switch the prompts press UP or DOWN arrow." << std::endl;
std::cerr << "- To move cursor press LEFT or RIGHT arrow." << std::endl;
std::cerr << "- To edit input press DELETE or BACKSPACE key." << std::endl;
std::cerr << "- To apply current prompt press TAB key.\n\n";
std::string command = input(dict);
std::cout << std::endl << command << std::endl << std::endl;
}
}
else {
std::cerr << message << std::endl;
}
return 0;
}
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 ---------------------
cd example/Release/
./example # Posix
example.exe # Windows
---------------------- OR RUN TESTS ---------------------
cd tests/Release/
./tests # Posix
tests.exe # Windows
Linking a dynamic library [Releases]
g++ -std=c++17 -o <executable> <paths/of/source/files> -L<path/to/shared/lib/link(.a)/folder> -I<path/to/include/folder> -lcliac -Wl,-rpath,<path/to/shared/lib/folder>
cl /EHsc /std:c++17 <paths/of/source/files> /Fe<executable>.exe /I <path/to/include> /link <path/to/shared/lib>
g++ -std=c++17 -o <executable>.exe <paths/of/source/files> -L<path/to/shared/lib/link(.a)> -I<path/to/include> -lcliac
Linking a static library [Releases]
g++ -std=c++17 -o <executable> <paths/of/source/files> -L<path/to/static/lib/folder> -I<path/to/include> -lcliac
cl /EHsc /std:c++17 /DBUILD_STATIC <paths/of/source/files> /Fe<executable>.exe /I <path/to/include/folder> /link <path/to/static/lib/foleder>
g++ -std=c++17 -DBUILD_STATIC -o <executable>.exe <paths/of/source/files> -L<path/to/static/lib/folder> -I<path/to/include/folder> -lcliac
A detailed description of the changes can be found in CHANGELOG.md