|
1 | 1 | import { Command } from 'commander' |
2 | | -import { runDataSetCommand } from '../data-set/run.js' |
3 | | -import type { DataSetCommandOptions } from '../data-set/types.js' |
4 | | -import { addAuthOptions } from '../utils/cli-options.js' |
| 2 | +import { runDataSetDetailsCommand, runDataSetListCommand } from '../data-set/run.js' |
| 3 | +import type { DataSetCommandOptions, DataSetListCommandOptions } from '../data-set/types.js' |
| 4 | +import { addAuthOptions, addProviderOptions } from '../utils/cli-options.js' |
5 | 5 |
|
6 | | -export const dataSetCommand = new Command('data-set') |
7 | | - .description('Inspect data sets managed through Filecoin Onchain Cloud') |
8 | | - .argument('[dataSetId]', 'Optional data set ID to inspect') |
9 | | - .option('--ls', 'List all data sets for the configured account') |
10 | | - .action(async (dataSetId: string | undefined, options) => { |
| 6 | +export const dataSetCommand = new Command('data-set').description( |
| 7 | + 'Inspect data sets managed through Filecoin Onchain Cloud' |
| 8 | +) |
| 9 | + |
| 10 | +export const dataSetShowCommand = new Command('show') |
| 11 | + .description('Display detailed information about a data set') |
| 12 | + .argument('<dataSetId>', 'Display detailed information about a data set') |
| 13 | + .action(async (dataSetId: string, options) => { |
11 | 14 | try { |
12 | 15 | const commandOptions: DataSetCommandOptions = { |
13 | 16 | ...options, |
14 | | - ls: options.ls, |
| 17 | + } |
| 18 | + const dataSetIdNumber = Number.parseInt(dataSetId, 10) |
| 19 | + if (Number.isNaN(dataSetIdNumber)) { |
| 20 | + throw new Error('Invalid data set ID') |
15 | 21 | } |
16 | 22 |
|
17 | | - await runDataSetCommand(dataSetId, commandOptions) |
| 23 | + await runDataSetDetailsCommand(dataSetIdNumber, commandOptions) |
18 | 24 | } catch (error) { |
19 | 25 | console.error('Data set command failed:', error instanceof Error ? error.message : error) |
20 | 26 | process.exit(1) |
21 | 27 | } |
22 | 28 | }) |
| 29 | +addAuthOptions(dataSetShowCommand) |
| 30 | + |
| 31 | +export const dataSetListCommand = new Command('list') |
| 32 | + .alias('ls') |
| 33 | + .description('List all data sets for the configured account') |
| 34 | + .option('--all', 'Show all data sets, not just the ones created with filecoin-pin', false) |
| 35 | + .action(async (options: DataSetListCommandOptions) => { |
| 36 | + try { |
| 37 | + await runDataSetListCommand(options) |
| 38 | + } catch (error) { |
| 39 | + console.error('Data set list command failed:', error instanceof Error ? error.message : error) |
| 40 | + process.exit(1) |
| 41 | + } |
| 42 | + }) |
| 43 | +addAuthOptions(dataSetListCommand) |
| 44 | +addProviderOptions(dataSetListCommand) |
23 | 45 |
|
24 | | -addAuthOptions(dataSetCommand) |
| 46 | +dataSetCommand.addCommand(dataSetShowCommand) |
| 47 | +dataSetCommand.addCommand(dataSetListCommand) |
0 commit comments