/* app/KMSubCommand.h
 *
 * Copyright (C) 2023 OpenKylin, Inc
 */

#ifndef __KMSUBCOMMAND_H__
#define __KMSUBCOMMAND_H__

#include <memory>
#include <vector>

#include "common/KMDynamicCreator.h"
#include "common/KMObject.h"

/**
 * @brief 	 kaiming-builder子命令基类
 */
class KMSubCommand : public KMObject
{
public:
    explicit KMSubCommand();
    virtual ~KMSubCommand();

    virtual int dispose(int argc, char **argv) = 0;

    void enableVfs();
};

struct SubCommandEntry
{
    std::string m_name;
    std::string m_description;
};

class KMSubCommandFactory
{
public:
    static const std::vector<SubCommandEntry> &subCommandEntrys();
    static std::unique_ptr<KMSubCommand> createKMSubCommand(const std::string &subCommand);

private:
    KMSubCommandFactory() = delete;
    ~KMSubCommandFactory() = delete;
};

#define REGISTER_SUBCOMMAND_DYNCREATE(subcommand, class_type) REGISTER_DYNCREATE(SubCommand_ ## subcommand, class_type)

#endif // !__KMSUBCOMMAND_H__
