lix/lix/libcmd/legacy.hh
eldritch horrors 9cf91b7385 cli infra: modernize legacy command interface
give legacy commands their program name and c++-converted argv directly
instead of passing on the (argc, argv) pair untouched. all are required
to process these things, and all of them do it in exactly the same way.
we can also remove a few old helpers only used to make this less awful.

Change-Id: I4ecd02343bca0cf85faf6fe043031d4f64c5f29c
2024-11-20 14:17:02 +00:00

25 lines
470 B
C++

#pragma once
///@file
#include <functional>
#include <list>
#include <map>
#include <string>
namespace nix {
typedef std::function<void(std::string, std::list<std::string>)> MainFunction;
struct LegacyCommands
{
typedef std::map<std::string, MainFunction> Commands;
static Commands * commands;
static void add(const std::string & name, MainFunction fun)
{
if (!commands) commands = new Commands;
(*commands)[name] = fun;
}
};
}