UNPKG

@ably/cli

Version:

Ably CLI for Pub/Sub, Chat and Spaces

55 lines (54 loc) 2.23 kB
import { Args, Flags } from "@oclif/core"; import { AblyBaseCommand } from "../../base-command.js"; export default class ChannelsLogs extends AblyBaseCommand { static args = { topic: Args.string({ default: "channel-lifecycle", description: "Log topic to subscribe to (currently only channel-lifecycle is supported)", }), }; static description = "Alias for ably logs channel-lifecycle subscribe"; static examples = [ "$ ably channels logs channel-lifecycle", "$ ably channels logs channel-lifecycle --rewind 10", ]; static flags = { ...AblyBaseCommand.globalFlags, json: Flags.boolean({ default: false, description: "Output results as JSON", }), rewind: Flags.integer({ default: 0, description: "Number of messages to rewind when subscribing", }), }; async run() { const { args, flags } = await this.parse(ChannelsLogs); // Currently only support channel-lifecycle if (args.topic !== "channel-lifecycle") { this.error(`Unsupported log topic: ${args.topic}. Currently only 'channel-lifecycle' is supported.`); return; } // Delegate to the original command await this.config.runCommand("logs:channel-lifecycle:subscribe", [ "--rewind", flags.rewind.toString(), ...(flags.json ? ["--json"] : []), ...(flags.json ? ["--pretty-json"] : []), // Forward all global flags ...(flags.host ? ["--host", flags.host] : []), ...(flags.env ? ["--env", flags.env] : []), ...(flags["control-host"] ? ["--control-host", flags["control-host"]] : []), ...(flags["access-token"] ? ["--access-token", flags["access-token"]] : []), ...(flags["api-key"] ? ["--api-key", flags["api-key"]] : []), ...(flags["client-id"] ? ["--client-id", flags["client-id"]] : []), ...(flags.app ? ["--app", flags.app] : []), ...(flags.endpoint ? ["--endpoint", flags.endpoint] : []), ]); } }