fmdetect
is a dead simple and very fast way of matching contents of a file to a string, specifically meant for framework detection. It can for example be used to identify usage of a library in a file to set specific options in an editor (example with vim below).
There are pre built binaries in the bin
directory. Copy the one built for your OS to where you keep user binaries.
If your OS is not in there, you can easily build it for your platform by following the build from source section.
For usage from an editor, please see vim_examples.md.
fmdetect
is meant to be used from a script but can be used from the command line as well:
# Found usage of the catch2 test library
$ fmdetect --paths tests/testfiles/catch2/010-TestCase.cpp --filetype cpp
catch2
# No output since there is nothing in README.md that matches any of the cpp regex values
$ fmdetect --paths README.md --filetype cpp
The general usage can be seen with the --help
flag.
$ fmdetect --help
usage:
fmdetect options
where options are:
-?, -h, --help display usage information
-f, --filetype <filetype> What is the current filetype? E.g. cpp
-p, --paths <paths> Path(s) to the file(s) being examined. May be
multiple separated by a comma (,).
This section is ordered as
- The input of `--filetype`
- The detected framework and the output on such detection
$ git clone https://github.com/srydell/fmdetect.git && cd fmdetect
$ mkdir build
$ cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D CMAKE_CXX_COMPILER=$(command -v clang++)
$ cmake --build build
$ cp build/bin/fmdetect <wherever you have binaries>
Pull requests are welcome.
If you would like another framework to be added, you can open an issue with one (or more) of the following:
- A description of how to include the framework. E.g. for
python
withunittest
:import unittest
- A suitable
regex
matching an identifier for that framework. Note that the matching is done line wise.
Please make sure to update tests as appropriate.
NOTE: The license excludes the files in tests/testfiles/*
since they are borrowed as tests from third party code.