UNPKG

beeline-cli

Version:

A terminal wallet for the Hive blockchain - type, sign, rule the chain

105 lines 4.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const neon_js_1 = require("../utils/neon.js"); const simple_plugins_js_1 = require("../utils/simple-plugins.js"); class Plugins extends core_1.Command { async run() { const { args } = await this.parse(Plugins); const theme = await (0, neon_js_1.getTheme)(); const pluginManager = (0, simple_plugins_js_1.getPluginManager)(); await pluginManager.initialize(); switch (args.action) { case 'list': await this.listPlugins(pluginManager); break; case 'install': if (!args.target) { console.log(theme.chalk.error(`${neon_js_1.neonSymbols.cross} Plugin path required for install`)); console.log('Usage: beeline plugins install <path>'); return; } await this.installPlugin(pluginManager, args.target); break; case 'uninstall': if (!args.target) { console.log(theme.chalk.error(`${neon_js_1.neonSymbols.cross} Plugin name required for uninstall`)); console.log('Usage: beeline plugins uninstall <name>'); return; } await this.uninstallPlugin(pluginManager, args.target); break; default: console.log(theme.chalk.error(`${neon_js_1.neonSymbols.cross} Unknown action: ${args.action}`)); } } async listPlugins(pluginManager) { const theme = await (0, neon_js_1.getTheme)(); const plugins = pluginManager.getPlugins(); const commands = pluginManager.getCommands(); if (plugins.length === 0) { console.log(theme.chalk.info(`${neon_js_1.neonSymbols.bullet} No plugins installed`)); console.log(''); console.log(theme.chalk.accent('Install a plugin:')); console.log(theme.chalk.highlight(' beeline plugins install <path>')); return; } console.log(theme.chalk.glow(`${neon_js_1.neonSymbols.diamond} Installed Plugins`)); console.log(''); for (const loadedPlugin of plugins) { const plugin = loadedPlugin.plugin; const pkg = loadedPlugin.packageJson; console.log(`${theme.chalk.highlight(plugin.name)} ${theme.chalk.accent(`v${plugin.version || pkg.version}`)}`); console.log(` ${plugin.description || pkg.description || 'No description'}`); console.log(` ${theme.chalk.info('Path:')} ${loadedPlugin.path}`); console.log(''); } // Show available commands const pluginCommands = Array.from(commands.entries()); if (pluginCommands.length > 0) { console.log(theme.chalk.accent('Available plugin commands:')); for (const [cmdName, cmd] of pluginCommands) { console.log(` ${theme.chalk.highlight(cmdName)} - ${cmd.description} ${theme.chalk.info(`(${cmd.pluginName})`)}`); } console.log(''); } } async installPlugin(pluginManager, pluginPath) { try { await pluginManager.installPlugin(pluginPath); } catch (error) { // Error already logged by plugin manager } } async uninstallPlugin(pluginManager, pluginName) { try { await pluginManager.uninstallPlugin(pluginName); } catch (error) { // Error already logged by plugin manager } } } Plugins.description = 'Manage plugins (install, list, uninstall)'; Plugins.examples = [ `$ beeline plugins list`, `$ beeline plugins install ./my-plugin`, `$ beeline plugins uninstall my-plugin` ]; Plugins.flags = { help: core_1.Flags.help({ char: 'h' }) }; Plugins.args = { action: core_1.Args.string({ description: 'action to perform', required: true, options: ['list', 'install', 'uninstall'] }), target: core_1.Args.string({ description: 'plugin name or path', required: false }) }; exports.default = Plugins; //# sourceMappingURL=plugins.js.map