diff --git a/src/index.ts b/src/index.ts index 6725f86..9f07715 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,11 +3,9 @@ import chalk from 'chalk' import { Command } from 'commander' -import { loadProcesses, disableProcess } from './lib/process/index.js' +import { loadProcesses, disableProcess, listProcess } from './lib/process/index.js' import { getAll } from './lib/process/api.js' import cliVersion from './version.js' -import { listHelper } from './lib/utils/cliHelper.js' - const { log, dir } = console const program = new Command() @@ -61,7 +59,7 @@ program const res: Process.RawPayload[] = await getAll(mapOptions(options)) let processes: Process.RawPayload[] - listHelper(res, processes, options) + listProcess(res, processes, options) process.exit(0) } catch (err) { @@ -74,6 +72,7 @@ program .command('create') .description('A command for persisting process flows onto the chain') .option('--dryRun', 'to validate process and response locally before persisting on the chain, default - false') + .option('--verbose', 'Returns all information about the transation, default - false') .option('-h, --host ', 'substrate blockchain host address or FQDM, default - "localhost"', 'localhost') .option('-p, --port ', 'specify host port number if it is not a default, default - 9944', '9944') .requiredOption('-u, --user ', 'specify substrate blockchain user URI') diff --git a/src/lib/process/index.ts b/src/lib/process/index.ts index 84b3473..299e9c8 100644 --- a/src/lib/process/index.ts +++ b/src/lib/process/index.ts @@ -54,6 +54,36 @@ export const loadProcesses = async ({ return res } +export const listProcess = async ( + res: Process.RawPayload[], + processes: Process.RawPayload[], + options: Process.CLIOptions) => { + const { dir } = console + if (options.active) { + processes = res.filter(({ status }) => status === 'Enabled') + } else if (options.disabled) { + processes = res.filter(({ status }) => status === 'Disabled') + } else { + processes = res + } + + if (options.raw) { + dir(processes, { depth: null }) + } else{ + dir( + processes.map((p) => { + return { + id: p.id, + version: p.version, + status: p.status, + ...options.verbose ? { program: p.program } : { } + } + }), + { depth: null } + ) + } +} + export const createProcess = async ( name: string, version: number, diff --git a/src/lib/utils/cliHelper.ts b/src/lib/utils/cliHelper.ts deleted file mode 100644 index 741ba9d..0000000 --- a/src/lib/utils/cliHelper.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const listHelper = async (res: Process.RawPayload[], processes: Process.RawPayload[], options: Process.CLIOptions) => { - const { dir } = console - if (options.active) { - processes = res.filter(({ status }) => status === 'Enabled') - } else if (options.disabled) { - processes = res.filter(({ status }) => status === 'Disabled') - } else { - processes = res - } - - if (options.raw) { - dir(processes, { depth: null }) - } else{ - dir( - processes.map((p) => { - return { - id: p.id, - version: p.version, - status: p.status, - ...options.verbose ? { program: p.program } : { } - } - }), - { depth: null } - ) - } -} \ No newline at end of file