@swell/cli
Version:
Swell's command line interface/utility
39 lines (38 loc) • 1.41 kB
JavaScript
import { Args, Flags } from '@oclif/core';
import { HttpMethod } from '../../lib/api.js';
import { SwellApiCommand, headerFlag } from '../../swell-api-command.js';
export default class ApiDelete extends SwellApiCommand {
static summary = 'Send a DELETE request to the Swell API.';
static description = `Remove existing resources from the Swell API.
Use --api frontend for public key authentication scoped to your app or user.`;
static args = {
path: Args.string({
description: 'API endpoint path (must start with /)',
required: true,
}),
};
static flags = {
live: Flags.boolean({
description: 'Use live environment instead of test',
default: false,
}),
api: Flags.string({
description: 'Use frontend or backend API (frontend uses public key auth).',
options: ['backend', 'frontend'],
default: 'backend',
}),
header: headerFlag,
};
static examples = [
'swell api delete /products/abc123',
'swell api delete /functions/my-app/clear-cache',
`swell api delete /functions/my-app/clear-cache -H 'Authorization: Bearer xxx'`,
'swell api delete /products/abc123 --api frontend',
];
get method() {
return HttpMethod.DELETE;
}
async run() {
await this.request(ApiDelete);
}
}