From e0de1ff28995969c9f95414b29fe253741c26940 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 13 Feb 2024 14:00:06 -1000 Subject: [PATCH] feat(cli): List all, list special --- packages/cli/src/commands/list.js | 10 +++++++--- packages/cli/src/endo.js | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/commands/list.js b/packages/cli/src/commands/list.js index e0ffcf84ab..548b005ce3 100644 --- a/packages/cli/src/commands/list.js +++ b/packages/cli/src/commands/list.js @@ -3,12 +3,16 @@ import os from 'os'; import { E } from '@endo/far'; import { withEndoHost } from '../context.js'; -export const list = async ({ directoryName }) => - withEndoHost({ os, process }, async ({ party }) => { +export const list = async ({ directoryName, special, all }) => + withEndoHost({ os, process }, async ({ host: party }) => { if (directoryName !== undefined) { party = E(party).lookup(directoryName); } - const petNames = await E(party).list(); + const petNames = await (() => { + if (all) return E(party).listAll(); + if (special) return E(party).listSpecial(); + return E(party).list(); + })(); for await (const petName of petNames) { console.log(petName); } diff --git a/packages/cli/src/endo.js b/packages/cli/src/endo.js index 14008acb5b..389ac66059 100644 --- a/packages/cli/src/endo.js +++ b/packages/cli/src/endo.js @@ -255,10 +255,13 @@ export const main = async rawArgs => { program .command('list [directory]') - .description('show names') - .action(async directoryName => { + .description('show names known to the current or specified directory') + .option('-s,--special', 'show special names') + .option('--all', 'show all names') + .action(async (directoryName, cmd) => { + const { special, all } = cmd.opts(); const { list } = await import('./commands/list.js'); - return list({ directoryName }); + return list({ directoryName, special, all }); }); program