const publishDoc = require('./doc')

interface PublishHandler {
  doc: () => void
}

async function publish(type: keyof PublishHandler){
  const publishHandler: PublishHandler = {
    doc: publishDoc, // 处理文档生成
  }
  if (Object.prototype.hasOwnProperty.call(publishHandler, type)) {
    await publishHandler[type]()
  }
}

// 发布命令的核心逻辑
async function execPublish(options: object) {
  Object.keys(options).forEach(async (type) => {
    await publish(type as keyof PublishHandler)
  })
}

export default execPublish
