UNPKG

filecoin-pin

Version:

Bridge IPFS content to Filecoin Onchain Cloud using familiar tools

52 lines 2.36 kB
import { Command } from 'commander'; import { runDataSetDetailsCommand, runDataSetListCommand } from '../data-set/run.js'; import { addAuthOptions, addProviderOptions } from '../utils/cli-options.js'; import { addMetadataOptions, resolveMetadataOptions } from '../utils/cli-options-metadata.js'; export const dataSetCommand = new Command('data-set') .alias('dataset') .description('Inspect data sets managed through Filecoin Onchain Cloud'); export const dataSetShowCommand = new Command('show') .description('Display detailed information about a data set') .argument('<dataSetId>', 'Display detailed information about a data set') .action(async (dataSetId, options) => { try { const commandOptions = { ...options, }; const dataSetIdNumber = Number.parseInt(dataSetId, 10); if (Number.isNaN(dataSetIdNumber)) { throw new Error('Invalid data set ID'); } await runDataSetDetailsCommand(dataSetIdNumber, commandOptions); } catch (error) { console.error('Data set command failed:', error instanceof Error ? error.message : error); process.exit(1); } }); addAuthOptions(dataSetShowCommand); export const dataSetListCommand = new Command('list') .alias('ls') .description('List all data sets for the configured account') .option('--all', 'Show all data sets, not just the ones created with filecoin-pin', false) .action(async (options) => { try { const { dataSetMetadata: _dataSetMetadata, datasetMetadata: _datasetMetadata, ...dataSetListOptionsFromCli } = options; const { dataSetMetadata } = resolveMetadataOptions(options); const normalizedOptions = { ...dataSetListOptionsFromCli, ...(dataSetMetadata ? { dataSetMetadata } : {}), }; await runDataSetListCommand(normalizedOptions); } catch (error) { console.error('Data set list command failed:', error instanceof Error ? error.message : error); process.exit(1); } }); addAuthOptions(dataSetListCommand); addProviderOptions(dataSetListCommand); addMetadataOptions(dataSetListCommand, { includePieceMetadata: false, includeDataSetMetadata: true }); dataSetCommand.addCommand(dataSetShowCommand); dataSetCommand.addCommand(dataSetListCommand); //# sourceMappingURL=data-set.js.map