Configuring input
Specifying a directory or file(s)
By default, unidep will browse the directory and build the dependency graph from files stored there. For example, to build the dependency graph between files in your src directory (and subdirectories):
unidep src
If you want to know the dependencies of only certain specific files, you can target them:
# Warning, this is probably not what you want
unidep src/main.c src/utils.c
However, unidep will only browse these two files. So a lot of dependencies might stay unresolved after browsing these two files. What you probably want to have are the dependencies of main.c
and utils.c
across your whole project. To do that, you can --include
the list of paths that unidep will be allowed to browse.
unidep src/main.c src/utils.c --include "src"
If you use an external library, you can include its path to allow unidep building a more complete dependency graph:
unidep src/main.c src/utils.c --include "src,/path/to/external-lib"
You can also --exclude
files within an included directory. --include
and --exclude
flags support glob patterns. For example, if you want to feature the headers of the external library, you can do:
unidep src src/main.c --include "src,/path/to/external-lib" --exclude "/path/to/external-lib/**/*.c"
Note that in the specific case above, including just the headers would be better:
unidep src/main.c --include "src,/path/to/external-lib/**/*.h"
Targeting specific languages
In case your project is using multiple languages, you can target specific languages using the language
flag. The following command creates two graphs (one for Rust files, one for Python files), and ignores all source files of other languages:
unidep src --language "rust,python"
Tracing function calls
By default, unidep identifies dependencies between files in your project. You can also output the dependencies expressed at a function level. To do that, use the --function
flag.
unidep src --function
You can also specify one or multiple functions of which to draw the dependency graph. Note that it can be complicated to resolve namespaces, so you may provide the relevant file(s) if another function with the same name is considered instead of the one you want. Use the --target-function
flag to provide the name of the function(s):
unidep src --target-function "do_fancy_stuff,do_more_fancy_stuff"