in src/commands/configuration/add.ts [20:48]
async run() {
const { flags } = await this.parse(ConfigurationAdd)
let { profile, mediaApiHost, apiKey } = flags
const { preventProfileChange } = flags
if (!mediaApiHost || !apiKey) {
if (!preventProfileChange) {
profile = await CliUx.ux.prompt('What profile shall we setup?', { default: profile })
}
mediaApiHost = await CliUx.ux.prompt(`[profile: ${profile}] What is the root for the Media API?`, { required: true })
apiKey = await CliUx.ux.prompt(`[profile: ${profile}] What is your API key?`, { required: true })
}
const maybeMediaApi = new Try(() => new URL(mediaApiHost!))
if (!maybeMediaApi.isSuccess) {
this.error(`${mediaApiHost!} is not a valid hostname`, { exit: 1 })
}
const newProfile = {
name: profile!,
mediaApiHost: maybeMediaApi.get(),
apiKey: apiKey!,
}
const configuration = new Configuration()
return configuration.addProfile(newProfile)
}