@grandlinex/easy-cli
Version:
Cli lib to perform common tasks
71 lines (70 loc) • 2.18 kB
JavaScript
import { XUtil } from '@grandlinex/core';
import { ShellCommand, } from '../../class/ShellComand.js';
import ArgUtil from '../../utils/ArgUtil.js';
import ProgressBar from '../../class/ProgressBar.js';
export default class DebugAction extends ShellCommand {
constructor(props) {
super({
...props,
name: 'debug',
description: 'Debug the CLI',
properties: [
{
key: 'null-field',
type: 'null',
required: false,
},
{
key: 'string-field',
type: 'string',
required: false,
},
{
key: 'string-default',
type: 'string',
required: false,
default: '1234994',
},
{
key: 'string-default-function',
type: 'string',
required: false,
default: async () => new Date().toISOString(),
prefill: 'editable',
editor: true,
},
{
key: 'number-field',
type: 'number',
required: false,
},
{
key: 'path-field',
type: 'path',
required: false,
dirOnly: true,
},
{
key: 'progress',
type: 'null',
required: false,
},
],
});
}
async run(parser) {
const progress = parser.getParameterNull('progress');
ArgUtil.printDebug(this, parser);
if (progress) {
const bar = new ProgressBar(100);
let count = 0;
while (count <= 100) {
bar.setState(count, ` ${count}/100`);
count++;
await XUtil.sleep(500);
}
bar.done();
}
return true;
}
}