Skip to content

Commit

Permalink
feat: added Paragon CLI version command
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Dec 11, 2023
1 parent efc45c6 commit 993d469
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/paragon-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
const chalk = require('chalk');
const themeCommand = require('../lib/install-theme');
const helpCommand = require('../lib/help');
const versionCommand = require('../lib/version');

const HELP_COMMAND = 'help';
const VERSION_COMMANDS = ['-v', '--version'];

const COMMANDS = {
/**
Expand Down Expand Up @@ -47,12 +49,21 @@ const COMMANDS = {
executor: helpCommand,
description: 'Displays help for available commands.',
},
version: {
executor: versionCommand,
description: 'Displays the current version of Paragon CLI.',
},
};

(async () => {
const [command] = process.argv.slice(2);
const executor = COMMANDS[command];

if (VERSION_COMMANDS.includes(command)) {
versionCommand();
return;
}

if (!executor) {
// eslint-disable-next-line no-console
console.log(chalk.red.bold('Unknown command. Usage: paragon <command>.'));
Expand Down
9 changes: 9 additions & 0 deletions lib/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable no-console */
const chalk = require('chalk');
const { version } = require('../package.json');

function versionCommand() {
console.log(`Paragon CLI version: ${chalk.bold(version)}`);
}

module.exports = versionCommand;

0 comments on commit 993d469

Please sign in to comment.