Skip to content

Commit

Permalink
feat(cli): List all, list special
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Feb 14, 2024
1 parent df056e5 commit e0de1ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions packages/cli/src/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/src/endo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e0de1ff

Please sign in to comment.