15static constexpr const char* DEFAULT_COMMAND =
"help";
18 {
"name",
'n',
RequiredArgument,
"Assign a name to the cache container; defaults to 'default' if not provided."},
19 {
"color", 0,
NoArgument,
"Enable colored output."},
20 {
"no-color", 0,
NoArgument,
"Disable colored output."},
22 {
"preprocessor", 0,
NoArgument,
"Forces the preprocessor to execute."},
23 {
"similarity",
'S',
RequiredArgument,
"Changes the similarity threshold to `SIMILARITY` for the current command only."},
24 {
"help",
'h',
NoArgument,
"Show this help message."},
29 std::unique_ptr<ICommand>& command,
32 return [&command, &commands](
Context& ctx)
mutable {
34 if (command.get() !=
nullptr) {
39 std::vector<char*> new_argv;
40 new_argv.push_back(
const_cast<char*
>(external_cmd.c_str()));
41 for (
int i = 2; i < ctx.argc; ++i) {
42 new_argv.push_back(ctx.argv[i]);
44 new_argv.push_back(
nullptr);
60 bool no_color = ctx.
options.
args.count(
"no-color") > 0;
69 auto it = ctx.options.args.find(
"similarity");
70 if (it != ctx.options.args.end()) {
71 double sim = std::stod(ctx.options.args[
"similarity"]);
79 return [cmd = std::move(command), &collector](
Context& ctx)
mutable {
80 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.
std::string program_name
Name of the program.
Represents a similarity graph between functions (paths).
void update_similarity(double new_similarity_threshold)
Updates similarity threshold.
static int run_process(const char *cmd, char *const argv[])
Executes an external program, replacing the current process (exec-style).
Function abstraction for temporary codebase.
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.
Path abstraction for temporary codebase.
Similarity relationships storage and analysis.
std::map< std::string, std::string > args
Map from option name to value.
Defines utility functions used across all files.