Echo Writes Code

main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "crucible/boot/main.hpp"
#include "crucible/core/arrays.hpp"

#include <iostream>
#include <string>

namespace crucible::boot::main
{
  static constexpr char const BULLET[] { "•" };

  static constexpr char const GREEN[] { "\x1b[0;32m" };

  static constexpr char const MAGENTA[] { "\x1b[0;35m" };

  static constexpr char const BRIGHT[] { "\x1b[1m" };

  static constexpr char const RESET[] { "\x1b[0m" };

  [[nodiscard]]
  static auto replicate(std::string const &pattern, std::size_t const amount) -> std::string
  {
    std::string result {};

    for (std::size_t i { 0 }; i < amount; ++i) {
      result += pattern;
    }

    return result;
  }

  auto launch(core::arrays::ImmutableSlice<std::string> const arguments) -> ExitStatus
  {
    static_cast<void>(arguments);

    std::string const full_header { "crucible-identify v" CRUCIBLE_VERSION };
    std::size_t const space_required { full_header.size() + 2 };
    std::string const horizontal_bars { replicate("─", space_required) };

    std::cout
      << "\n"
      << BRIGHT << "╭" << horizontal_bars << "╮\n" << RESET
      << BRIGHT << "│ " << full_header << " │\n" << RESET
      << BRIGHT << "╰" << horizontal_bars << "╯\n" << RESET
      << "\n"
      << BRIGHT << "Build information\n" << RESET
      << BRIGHT << "─────────────────\n" << RESET
      << "\n"
      << BULLET << " " << MAGENTA << "CRUCIBLE_CMAKE_VERSION" << RESET << " is " << GREEN << CRUCIBLE_CMAKE_VERSION << RESET << "\n"
      << BULLET << " " << MAGENTA << "CRUCIBLE_CXX_COMPILER_ID" << RESET << " is " << GREEN << CRUCIBLE_CXX_COMPILER_ID << RESET << "\n"
      << BULLET << " " << MAGENTA << "CRUCIBLE_CXX_COMPILER_VERSION" << RESET << " is " << GREEN << CRUCIBLE_CXX_COMPILER_VERSION << RESET << "\n"
      << BULLET << " " << MAGENTA << "CRUCIBLE_TARGET_SYSTEM_ARCHITECTURE" << RESET << " is " << GREEN << CRUCIBLE_TARGET_SYSTEM_ARCHITECTURE << RESET << "\n"
      << BULLET << " " << MAGENTA << "CRUCIBLE_TARGET_SYSTEM_ID" << RESET << " is " << GREEN << CRUCIBLE_TARGET_SYSTEM_ID << RESET << "\n"
      << BULLET << " " << MAGENTA << "CRUCIBLE_TARGET_SYSTEM_VERSION" << RESET << " is " << GREEN << CRUCIBLE_TARGET_SYSTEM_VERSION << RESET << "\n"
      << "\n";

    return ExitStatus::Success;
  }
}