#include <chrono>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <unordered_set>
#include <vector>
#include "include/CLI11.hpp"
#include "include/termstyle.hpp"
|
| bool | checkIgnore (const fs::path &path) |
| | Check if the file should be ignored.
|
| |
| std::string | subtractPath (const fs::path &path, const fs::path &base) |
| | Subtract the base path from the given path.
|
| |
| std::string | addSpaces (int depth, bool isEnd) |
| | Add spaces to the output based on the depth and if it's the end of the branch.
|
| |
| void | print (std::string str) |
| | Print the string to the console and the file if the flag is set.
|
| |
| void | printDir (const fs::path &path, const std::unordered_set< std::string > &ignoreFiles, int maxDepth, int depth) |
| | Print the directory tree.
|
| |
| void | initFile () |
| | Initialize the output file.
|
| |
| void | termstyle_init () |
| | Initialize the termstyle presets.
|
| |
| int | main (int argc, char *argv[]) |
| | Main function.
|
| |
|
|
const std::string | outFile = "dir_tree.txt" |
| | Default output file.
|
| |
|
std::ofstream | file |
| | Output file stream.
|
| |
|
bool | no_ignore = false |
| | Flag to ignore files.
|
| |
|
bool | to_file = false |
| | Flag to output to a file.
|
| |
|
bool | use_prev_cmd = false |
| | Flag to use the previous command.
|
| |
|
int | maxDepth = -1 |
| | Default recursion depth (-1 means infinite)
|
| |
|
std::string | dirName = "" |
| | Default directory name.
|
| |
|
std::unordered_set< std::string > | ignoreFiles |
| | Files to ignore.
|
| |
|
std::unordered_set< std::string > | noContent |
| | Directories to ignore contents.
|
| |
◆ addSpaces()
| std::string addSpaces |
( |
int | depth, |
|
|
bool | isEnd ) |
Add spaces to the output based on the depth and if it's the end of the branch.
- Parameters
-
| depth | The depth of the current directory. |
| isEnd | True if it's the end of the branch, false otherwise. |
- Returns
- The string with the spaces.
◆ checkIgnore()
| bool checkIgnore |
( |
const fs::path & | path | ) |
|
Check if the file should be ignored.
- See also
- ignoreFiles
-
no_ignore
- Parameters
-
| path | The path to the file. |
- Returns
- True if the file should be ignored, false otherwise.
◆ initFile()
Initialize the output file.
If the flag is set, the file will be created or truncated if it is already present.
- Returns
- void
◆ main()
| int main |
( |
int | argc, |
|
|
char * | argv[] ) |
Main function.
- Parameters
-
| argc | The number of command line arguments. |
| argv | The command line arguments. |
- Returns
- 0 if the program executed successfully, 1 otherwise.
◆ print()
| void print |
( |
std::string | str | ) |
|
Print the string to the console and the file if the flag is set.
- See also
- to_file
- Parameters
-
- Returns
- void
◆ printDir()
| void printDir |
( |
const fs::path & | path, |
|
|
const std::unordered_set< std::string > & | ignoreFiles, |
|
|
int | maxDepth, |
|
|
int | depth ) |
Print the directory tree.
- Parameters
-
| path | The path to the directory. |
| ignoreFiles | The files to ignore. |
| maxDepth | The maximum depth of recursion. |
| depth | The current depth of recursion. Default should be 1. |
- Returns
- void
◆ subtractPath()
| std::string subtractPath |
( |
const fs::path & | path, |
|
|
const fs::path & | base ) |
Subtract the base path from the given path.
subtractPath("/home/user/file.txt", "/home/user") -> "file.txt"
- Parameters
-
| path | The path to subtract from. |
| base | The base path. |
◆ termstyle_init()
Initialize the termstyle presets.
- Returns
- void