Skip to content

Commit de5fe76

Browse files
committed
cli documentation changes and small stylistic modifications
1 parent e38655c commit de5fe76

5 files changed

Lines changed: 39 additions & 52 deletions

File tree

src/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
| File | Purpose |
22
|------|---------|
3-
| `cli.cpp` | Entire CLI tool code |
43
| `vmaware.hpp` | Official and original library header, most likely what you're looking for. |
4+
| | |
5+
| `cli/main.cpp` | CLI entry point and argument parsing |
6+
| `cli/output.hpp` | Output formatting (general display and JSON) |
7+
| `cli/strings.hpp` | ANSI color strings, argument enums, and global counters |
8+
| `cli/types.hpp` | Shared primitive type aliases |
9+
| `cli/sha256.hpp` | SHA-256 implementation used by the CLI |
10+
| `cli/windows_cli.hpp` | Windows-specific ANSI support and string utilities |
511

612
<br>
713

src/cli/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131

3232
#include "types.hpp"
3333
#include "strings.hpp"
34-
#include "windows_cli.hpp"
3534
#include "output.hpp"
3635

36+
#if (CLI_WINDOWS)
37+
#include "windows_cli.hpp"
38+
#endif
39+
3740
constexpr const char* ver = "2.7.0";
3841
constexpr const char* date = "April 2026";
3942

src/cli/output.cpp

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,14 @@ const char* color(const u8 score, const bool is_hardened) {
2323
}
2424

2525
if (arg_bitset.test(DYNAMIC)) {
26-
if (score == 0) {
27-
return red.c_str();
28-
}
29-
30-
if (score <= 12) {
31-
return red.c_str();
32-
}
33-
34-
if (score <= 25) {
35-
return red_orange.c_str();
36-
}
37-
38-
if (score < 50) {
39-
return red_orange.c_str();
40-
}
41-
42-
if (score <= 62) {
43-
return orange.c_str();
44-
}
45-
46-
if (score <= 75) {
47-
return green_orange.c_str();
48-
}
49-
50-
if (score < 100) {
51-
return green.c_str();
52-
}
53-
54-
if (score == 100) {
55-
return green.c_str();
56-
}
26+
if (score == 0) { return red.c_str(); }
27+
if (score <= 12) { return red.c_str(); }
28+
if (score <= 25) { return red_orange.c_str(); }
29+
if (score < 50) { return red_orange.c_str(); }
30+
if (score <= 62) { return orange.c_str(); }
31+
if (score <= 75) { return green_orange.c_str(); }
32+
if (score < 100) { return green.c_str(); }
33+
if (score == 100) { return green.c_str(); }
5734
} else {
5835
if (score == 100) {
5936
return green.c_str();

src/cli/sha256.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ void SHA256::transform() {
6868
};
6969

7070
u32 m[64]{};
71+
7172
for (u32 i = 0, j = 0; i < 16; ++i, j += 4) {
7273
m[i] = (u32)buf[j] << 24 | (u32)buf[j + 1] << 16 | (u32)buf[j + 2] << 8 | (u32)buf[j + 3];
7374
}
75+
7476
for (u32 i = 16; i < 64; ++i) {
7577
m[i] = sig1(m[i - 2]) + m[i - 7] + sig0(m[i - 15]) + m[i - 16];
7678
}
@@ -125,8 +127,7 @@ void SHA256::final(u8 out[32]) {
125127
while (i < 56) {
126128
buf[i++] = 0;
127129
}
128-
}
129-
else {
130+
} else {
130131
buf[i++] = 0x80;
131132
while (i < 64) {
132133
buf[i++] = 0;

src/cli/strings.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
#include "strings.hpp"
22

3-
const std::string TH_DIM = "\x1B[38;2;60;60;60m";
4-
const std::string TH_MED = "\x1B[38;2;120;120;120m";
3+
const std::string TH_DIM = "\x1B[38;2;60;60;60m";
4+
const std::string TH_MED = "\x1B[38;2;120;120;120m";
55
const std::string TH_WHITE = "\x1B[38;2;255;255;255m";
6-
const std::string TH_RST = "\x1B[0m";
6+
const std::string TH_RST = "\x1B[0m";
77

88
#if (CLI_WINDOWS)
99
const std::string TH_BRIGHT = "\x1B[38;2;180;180;180m";
10-
const std::string TH_RED = "\x1B[38;2;220;0;0m";
10+
const std::string TH_RED = "\x1B[38;2;220;0;0m";
1111
#endif
1212

13-
std::string bold = "\x1B[1;97m";
14-
std::string underline = "\x1B[4m";
15-
std::string ansi_exit = "\x1B[0m";
16-
std::string red = "\x1B[31m";
17-
std::string orange = "\x1B[38;2;180;50;0m";
18-
std::string green = "\x1B[38;2;60;60;60m";
19-
std::string red_orange = "\x1B[31m";
13+
std::string bold = "\x1B[1;97m";
14+
std::string underline = "\x1B[4m";
15+
std::string ansi_exit = "\x1B[0m";
16+
std::string red = "\x1B[31m";
17+
std::string orange = "\x1B[38;2;180;50;0m";
18+
std::string green = "\x1B[38;2;60;60;60m";
19+
std::string red_orange = "\x1B[31m";
2020
std::string green_orange = "\x1B[38;2;60;60;60m";
21-
std::string grey = "\x1B[38;2;60;60;60m";
22-
std::string white = "\x1B[38;2;255;255;255m";
21+
std::string grey = "\x1B[38;2;60;60;60m";
22+
std::string white = "\x1B[38;2;255;255;255m";
2323

2424
std::bitset<arg_bits> arg_bitset;
2525

2626
u8 unsupported_count = 0;
27-
u8 supported_count = 0;
28-
u8 no_perms_count = 0;
29-
u8 disabled_count = 0;
27+
u8 supported_count = 0;
28+
u8 no_perms_count = 0;
29+
u8 disabled_count = 0;
3030

31-
std::string tag_detected = ("\x1B[97m[\x1B[31m DETECTED \x1B[97m]\x1B[0m");
31+
std::string tag_detected = ("\x1B[97m[\x1B[31m DETECTED \x1B[97m]\x1B[0m");
3232
std::string tag_not_detected = (" \x1B[97m[\x1B[90mNOT DETECTED\x1B[97m]\x1B[0m");

0 commit comments

Comments
 (0)