UNPKG

@lxdhub/api

Version:

Display, search and copy LXD-images using a web interface.

33 lines (30 loc) 938 B
import { Command, command, metadata, option, Options } from 'clime'; import * as Fs from 'fs'; import * as Path from 'path'; export class DefaultOptions extends Options { @option({ flag: 'v', description: 'The version of lxdhub-api', toggle: true, required: false }) version: boolean = false; } @command({ description: 'lxdhub-api is a CLI-tool to manage the LXDHub API.' }) export default class APICommand extends Command { @metadata async execute( options: DefaultOptions ) { const isVersion = !!options.version; if (isVersion) { const packageJsonPath = Path.join(__dirname, '../../package.json'); const packageJsonContent = Fs.readFileSync(packageJsonPath, 'utf8'); const packageJson = JSON.parse(packageJsonContent); return packageJson.version; } return APICommand.getHelp(); } }