Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BD-46] feat: added Paragon CLI version command #2921

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bin/paragon-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
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 commandAliases = {
'-v': 'version',
'--version': 'version',
};

const COMMANDS = {
/**
Expand Down Expand Up @@ -47,11 +52,16 @@ 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];
const resolvedCommand = commandAliases[command] || command;
const executor = COMMANDS[resolvedCommand];

if (!executor) {
// eslint-disable-next-line no-console
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;