-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.js
executable file
·30 lines (27 loc) · 1.03 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
import {program} from 'commander';
import {downloadIcon} from './index.js';
program
.name('iconify-svelte')
.description('Download Iconify icons as Svelte components')
.argument('<icon>', 'icon collection (e.g., mdi)')
.option('-o, --output <dir>', 'output directory', 'src/icons')
.option('--withts', 'generate TypeScript version', true)
.option('--withjs', 'generate JavaScript version', false)
.action(async (icon, options) => {
try {
const results = await downloadIcon(icon, {
outputDir: options.output, withTs: options.withts, withJs: options.withjs
});
if (results.length) {
console.log('https://github.com/friendofsvelte/svelicon ✨ \n');
}
results.forEach(file => {
console.log(`🚀 Successfully created: ${file}`);
});
} catch (error) {
console.error('Error:', error.message);
process.exit(1);
}
});
program.parse();