diff options
| author | Amlal <amlal@nekernel.org> | 2025-05-01 11:59:48 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-05-01 11:59:48 +0200 |
| commit | 1e8b22f34ce423b23d1b4c4ea59ed16aa29842d8 (patch) | |
| tree | 270042aea172fa5785303763cb739ea5ce3e4f69 /tooling/mkfs.h | |
| parent | c613812ef130388ac82b24bdce12389de96b7ce4 (diff) | |
tooling, fs: Improve tooling and clean up HeFS filesystem code.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'tooling/mkfs.h')
| -rw-r--r-- | tooling/mkfs.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tooling/mkfs.h b/tooling/mkfs.h new file mode 100644 index 00000000..650261db --- /dev/null +++ b/tooling/mkfs.h @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include <iostream> +#include <string> +#include <tooling/rang.h> + +/// @internal +namespace mkfs { +/// @brief Helper function to get the option value from command line arguments. +template <typename CharType> +inline std::basic_string<CharType> get_option(const std::basic_string<CharType>& args, + const std::basic_string<CharType>& option) { + size_t pos = args.find(option + CharType('=')); + + if (pos != std::string::npos) { + size_t start = pos + option.length() + 1; + size_t end = args.find(' ', start); + return args.substr(start, end - start); + } + + return std::basic_string<CharType>{}; +} + +inline auto console_out() -> std::ostream& { + std::ostream& conout = std::cout; + conout << rang::fg::red << "mkfs: " << rang::style::reset; + + return conout; +} +} // namespace mkfs
\ No newline at end of file |
