about summary refs log blame commit diff
path: root/third_party/nix/src/nix/legacy.hh
blob: a0fc88da244cf208953c92ac209a0a735778a0c8 (plain) (tree)
1
2
3
4
5
6
7
8
9



                     
                 


               
                                                      
 
                              
                                                       
                            
 
                                                                    


                              

                            

  
                   
#pragma once

#include <functional>
#include <map>
#include <string>

namespace nix {

typedef std::function<void(int, char**)> MainFunction;

struct RegisterLegacyCommand {
  using Commands = std::map<std::string, MainFunction>;
  static Commands* commands;

  RegisterLegacyCommand(const std::string& name, MainFunction fun) {
    if (!commands) {
      commands = new Commands;
    }
    (*commands)[name] = fun;
  }
};

}  // namespace nix