UNPKG

@swell/cli

Version:

Swell's command line interface/utility

35 lines (34 loc) 1.25 kB
import { Args, Flags } from '@oclif/core'; import { HttpMethod } from '../../lib/api.js'; import { SwellApiCommand } from '../../swell-api-command.js'; export default class ApiPut extends SwellApiCommand { static summary = 'Send a PUT request to the Swell API.'; static description = `Update existing resources in the Swell Backend API. You can provide a JSON body directly or specify a file path containing JSON data.`; static args = { path: Args.string({ description: 'API endpoint path (must start with /)', required: true, }), }; static flags = { body: Flags.string({ description: 'Request body (inline JSON or file path)', }), live: Flags.boolean({ description: 'Use live environment instead of test', default: false, }), }; static examples = [ 'swell api put /products/{id} --body \'{"id": "abc123", "name": "Updated"}\'', 'swell api put /products/abc123 --body ./product.json', 'swell api put /functions/my-app/update-stock --body \'{"sku":"abc","qty":10}\'', ]; get method() { return HttpMethod.PUT; } async run() { await this.request(ApiPut); } }