UNPKG

@ably/cli

Version:

Ably CLI for Pub/Sub, Chat and Spaces

30 lines (29 loc) 1.25 kB
import { AblyBaseCommand } from "../base-command.js"; import { getVersionInfo, formatVersionString, formatVersionJson, formatReleaseStatus, } from "../utils/version.js"; export default class Version extends AblyBaseCommand { static description = "Display CLI version information"; static examples = [ "<%= config.bin %> version", "<%= config.bin %> version --json", ]; // Hide this command from help output (users should use --version flag instead) static hidden = true; // Import global flags (like --json and --pretty-json) static flags = { ...AblyBaseCommand.globalFlags, }; async run() { const { flags } = await this.parse(Version); // Get CLI version information using the shared utility const versionInfo = getVersionInfo(this.config); // Check if output should be in JSON format if (this.shouldOutputJson(flags)) { this.log(formatVersionJson(versionInfo, Boolean(flags["pretty-json"]))); } else { // Use shared string formatting and display release status this.log(formatVersionString(this.config)); this.log(formatReleaseStatus(this.config.version, true)); } } }