14static constexpr const char* DEFAULT_COMMAND =
"help";
17 {
"name",
'n',
RequiredArgument,
"Assign a name to the cache container; defaults to 'default' if not provided."},
18 {
"color", 0,
NoArgument,
"Enable colored output."},
19 {
"no-color", 0,
NoArgument,
"Disable colored output."},
21 {
"similarity",
'S',
RequiredArgument,
"Changes the similarity threshold to `SIMILARITY` for the current command only."},
22 {
"help",
'h',
NoArgument,
"Show this help message."},
27 std::unique_ptr<ICommand>& command,
30 return [&command, &commands](
Context& ctx)
mutable {
32 if (command.get() !=
nullptr) {
37 std::vector<char*> new_argv;
38 new_argv.push_back(
const_cast<char*
>(external_cmd.c_str()));
39 for (
int i = 2; i < ctx.argc; ++i) {
40 new_argv.push_back(ctx.argv[i]);
42 new_argv.push_back(
nullptr);
64 auto result = table.
load();
70 "Cache generated with Arkanjo v" +
71 (!params.version.empty() ? params.version :
"?.?.?") +
72 " may be incompatible with the current version v" +
74 ". Results may be inaccurate.");
77 if (
auto similarity = ctx.options.get_as<
double>(
"similarity"))
85 return [cmd = std::move(command), &collector](
Context& ctx)
mutable {
86 return cmd->validate(ctx.options) && cmd->do_run(ctx.command_name, ctx.options, &collector);
An error is thrown when an unknown command is passed.
static Config & config()
Gets the singleton configuration instance.
static PreprocessRunParams read_current_run_params()
read preprocessing parameters runs
Represents a similarity graph between functions (paths).
void update_similarity(double new_similarity_threshold)
Updates similarity threshold.
Cache_Compatibility load()
static int run_process(const char *cmd, char *const argv[])
Executes an external program, replacing the current process (exec-style).
std::unique_ptr< ICommand > get_command(const std::string &name, const std::vector< std::pair< std::vector< std::string >, CommandFactory > > &commands)
std::function< std::unique_ptr< ICommand >()> CommandFactory
Step setup_command_step(std::unique_ptr< ICommand > &command, const std::vector< std::pair< std::vector< std::string >, CommandsRegistry::CommandFactory > > &commands)
Step similarity_step(Similarity_Table &table)
constexpr CliOption global_long_opts[]
bool formatter_step(Context &ctx)
Step command_run_step(std::shared_ptr< ICommand > command, const OptionsCollector &collector)
Main command orchestration interface.
std::function< bool(Context &)> Step
#define OPTION_END
This marks the end of a long array of options.
Logical path abstraction for source code elements.
Similarity relationships storage and analysis.
bool has(const std::string &name) const
Checks whether an option exists.
std::string project_version
Current project version.
std::string program_name
Name of the program.