const login = require("./login")
const Logger = require("./Logger")

module.exports = asyncHandler => argv => Logger.wrap(login, false)(argv).then(res => res && Logger.wrap(async argv => {
  try {
    return await asyncHandler(res.api, argv);
  } finally {
    res.api.close && res.api.close()
  }
}, true)(argv))
