Skip to content

Commit cbe18da

Browse files
committed
Add RegistryType.Apps and support for open command.
1 parent 8c1b8bd commit cbe18da

5 files changed

Lines changed: 25 additions & 6 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"node": ">=18"
4040
},
4141
"dependencies": {
42-
"@open-audio-stack/core": "^0.1.38",
42+
"@open-audio-stack/core": "^0.1.40",
4343
"cli-table3": "^0.6.5",
4444
"commander": "^12.1.0",
4545
"ora": "^9.0.0"

src/commands/open.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Command } from 'commander';
2+
import { CliOptions } from '../types/options.js';
3+
import { inputGetParts, ManagerLocal } from '@open-audio-stack/core';
4+
5+
export function open(command: Command, manager: ManagerLocal) {
6+
command
7+
.command('open <input> [options...]')
8+
.option('-l, --log', 'Enable logging')
9+
.description('Open a package by slug/version')
10+
.action(async (input: string, options: string[], cliOptions: CliOptions) => {
11+
if (cliOptions.log) manager.logEnable();
12+
else manager.logDisable();
13+
const [slug, version] = inputGetParts(input);
14+
await manager.open(slug, version, options);
15+
});
16+
}

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { filter } from './commands/filter.js';
99
import { get } from './commands/get.js';
1010
import { install } from './commands/install.js';
1111
import { list } from './commands/list.js';
12+
import { open } from './commands/open.js';
1213
import { reset } from './commands/reset.js';
1314
import { scan } from './commands/scan.js';
1415
import { search } from './commands/search.js';
@@ -20,7 +21,7 @@ const program = new Command();
2021
program.addCommand(configCmd);
2122

2223
// Dynamically add commands for each registry type.
23-
const types = [RegistryType.Plugins, RegistryType.Presets, RegistryType.Projects];
24+
const types = [RegistryType.Apps, RegistryType.Plugins, RegistryType.Presets, RegistryType.Projects];
2425
for (const type of types) {
2526
const command: Command = program.command(type);
2627
const manager: ManagerLocal = new ManagerLocal(type as RegistryType, isTests() ? CONFIG_LOCAL_TEST : undefined);
@@ -31,6 +32,7 @@ for (const type of types) {
3132
get(command, manager);
3233
install(command, manager);
3334
list(command, manager);
35+
open(command, manager);
3436
reset(command, manager);
3537
scan(command, manager);
3638
search(command, manager);

tests/__snapshots__/index.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Options:
99
1010
Commands:
1111
config View/update configuration
12+
apps
1213
plugins
1314
presets
1415
projects

0 commit comments

Comments
 (0)