apio
140910763e
All checks were successful
Build and test / build (push) Successful in 1m56s
Why are command-line utilities stored in "apps"? And why are apps like "editor" or "terminal" top-level directories? Command-line utilities now go in "utils". GUI stuff now goes in "gui". This includes: libui -> gui/libui, wind -> gui/wind, GUI apps -> gui/apps, editor&terminal -> gui/apps... System services go in "system".
31 lines
787 B
C++
31 lines
787 B
C++
#include <luna/SHA.h>
|
|
#include <os/ArgumentParser.h>
|
|
#include <os/File.h>
|
|
|
|
Result<int> luna_main(int argc, char** argv)
|
|
{
|
|
Vector<StringView> files;
|
|
|
|
os::ArgumentParser parser;
|
|
parser.add_description("Calculate SHA256 hashes for a series of files."_sv);
|
|
parser.add_system_program_info("sha256sum"_sv);
|
|
parser.set_vector_argument(files, "files"_sv, "-"_sv);
|
|
parser.parse(argc, argv);
|
|
|
|
for (auto path : files)
|
|
{
|
|
auto file = TRY(os::File::open_input_file(path));
|
|
auto data = TRY(file->read_all());
|
|
|
|
SHA256 sha;
|
|
|
|
TRY(sha.append(data.data(), data.size()));
|
|
auto digest = TRY(sha.digest());
|
|
auto string = TRY(digest.to_string());
|
|
|
|
os::println("%s %s", string.chars(), path.chars());
|
|
}
|
|
|
|
return 0;
|
|
}
|