import commitTag from './tag'

interface CommandHandler {
  tag: () => void
}

interface CommandOptions {
  tag: boolean
}

type Types = keyof CommandOptions

async function exec(type: Types) {
  const paramsHandler: CommandHandler = {
    tag: commitTag, // 自动打git标签
  }
  const fn = paramsHandler[type]
  await fn()
}

// 发布命令的核心逻辑
async function execGit(CommandOptions: CommandOptions) {
  if(CommandOptions.tag) {
    await exec('tag')
  }
}

export default execGit
