mirror of https://github.com/abpframework/abp.git
1 changed files with 14 additions and 25 deletions
@ -1,40 +1,29 @@ |
|||||
#!/usr/bin/env node |
#!/usr/bin/env node |
||||
import chalk from 'chalk'; |
import chalk from 'chalk'; |
||||
import path from 'path'; |
|
||||
import commander from 'commander'; |
import commander from 'commander'; |
||||
|
import ora from 'ora'; |
||||
import { axiosInstance } from './utils/axios'; |
import { axiosInstance } from './utils/axios'; |
||||
const clear = require('clear'); |
const clear = require('clear'); |
||||
const figlet = require('figlet'); |
const figlet = require('figlet'); |
||||
|
|
||||
clear(); |
clear(); |
||||
|
|
||||
console.log( |
console.log(chalk.red(figlet.textSync('ABP', { horizontalLayout: 'full' }))); |
||||
chalk.red( |
|
||||
figlet.textSync('abp', { horizontalLayout: 'full' }) |
|
||||
) |
|
||||
); |
|
||||
|
|
||||
commander |
commander |
||||
.version('0.0.1') |
.version('0.0.1') |
||||
.description("An example CLI for ordering pizza's") |
.description('ABP Client Generator') |
||||
.option('-p, --peppers', 'Add peppers') |
.option('-u, --ui', 'UI option (Angular)') |
||||
.option('-P, --pineapple', 'Add pineapple') |
|
||||
.option('-b, --bbq', 'Add bbq sauce') |
|
||||
.option('-c, --cheese <type>', 'Add the specified type of cheese [marble]') |
|
||||
.option('-C, --no-cheese', 'You do not want any cheese') |
|
||||
.parse(process.argv); |
.parse(process.argv); |
||||
|
|
||||
if (!process.argv.slice(2).length) { |
if (!process.argv.slice(2).length) { |
||||
commander.outputHelp(); |
commander.outputHelp(); |
||||
} |
process.exit(1); |
||||
|
} |
||||
|
|
||||
console.log('you ordered a pizza with:'); |
const loading = ora('Waiting for API response... \n'); |
||||
if (commander.peppers) console.log(' - peppers'); |
loading.start(); |
||||
if (commander.pineapple) console.log(' - pineapple'); |
(async function() { |
||||
if (commander.bbq) console.log(' - bbq'); |
const data = await axiosInstance.get('a'); |
||||
const cheese: string = true === commander.cheese ? 'marble' : commander.cheese || 'no'; |
loading.stop(); |
||||
console.log(' - %s cheese', cheese); |
})(); |
||||
|
|
||||
console.log((async () => { |
|
||||
console.log(await axiosInstance.get('https://swapi.co/api/people/1')) |
|
||||
})()) |
|
||||
|
|||||
Loading…
Reference in new issue