From 933fb1b077c8d7e25819504c52141da0531452b4 Mon Sep 17 00:00:00 2001 From: David Diaz Date: Wed, 27 Dec 2017 18:32:35 -0600 Subject: [PATCH] Added an init command to the CLI. Init will create a config file with the endpoint filled to whatever is set. It also has helpful comments to guide you through creating a config file. --- bin/beau | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/bin/beau b/bin/beau index ec18056..9eb3897 100755 --- a/bin/beau +++ b/bin/beau @@ -116,6 +116,51 @@ program } }); +program + .command('init') + .option( + '-e --endpoint ', + 'Allows you to set the default endpoint', + null + ) + .action(({ endpoint }) => { + const newFile = `# Beau.yml + +version: 1${endpoint === null ? ` +# endpoint: http://example.com +` : ` +endpoint: ${endpoint} +`} + +# defaults: +# params: +# userId: 25 + + + +# GET /profile: profile + +# GET /posts: +# alias: posts +# params: +# order: ASC + +# POST /profile: +# alias: save-profile +# headers: +# authentication: Bearer token +# payload: +# name: David +# lastname: Diaz +`; + if (!fs.existsSync('beau.yml')) { + fs.writeFileSync('beau.yml', newFile); + console.info('beau.yml created!'); + } else { + console.error('beau.yml already exists.'); + } + }); + program.parse(process.argv); if (!program.args.length) program.help();