Run recently merged pull request code through Prettier
Enable console.log in eslint
This commit is contained in:
@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": "airbnb-base"
|
"extends": "airbnb-base",
|
||||||
}
|
"rules": {
|
||||||
|
"no-console": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
77
index.js
77
index.js
@ -8,13 +8,46 @@ const partNumbers = require('./partNumbers.json');
|
|||||||
|
|
||||||
// Define command line args accepted.
|
// Define command line args accepted.
|
||||||
const optionDefinitions = [
|
const optionDefinitions = [
|
||||||
{ name: 'carrier', type: String, defaultValue: 'TMOBILE', description: "Define which carrier to search for. Accepted options are: 'ATT', 'SPRING', 'TMOBILE', 'VERIZON'."},
|
{
|
||||||
{ name: 'model', type: String, defaultValue: 'x', description: "Define which model iPhone to search for. 'x' is the only option currently available."},
|
name: 'carrier',
|
||||||
{ name: 'color', type: String, defaultValue: 'gray', description: "Define which color iPhone to search for. Accepted options are: 'silver', 'gray'."},
|
type: String,
|
||||||
{ name: 'storage', type: String, defaultValue: '256', description: "Define which storage size to search for. Accepted options are: '64', '256'."},
|
defaultValue: 'TMOBILE',
|
||||||
{ name: 'zip', type: String, defaultOption: true, description: "Define the area to search in by zip code. This option is required."},
|
description:
|
||||||
{ name: 'delay', type: Number, defaultValue: 30, description: "Define the number of seconds between requests."},
|
"Define which carrier to search for. Accepted options are: 'ATT', 'SPRING', 'TMOBILE', 'VERIZON'.",
|
||||||
{ name: 'help', type: Boolean, description: "Display this help screen."},
|
},
|
||||||
|
{
|
||||||
|
name: 'model',
|
||||||
|
type: String,
|
||||||
|
defaultValue: 'x',
|
||||||
|
description:
|
||||||
|
"Define which model iPhone to search for. 'x' is the only option currently available.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'color',
|
||||||
|
type: String,
|
||||||
|
defaultValue: 'gray',
|
||||||
|
description:
|
||||||
|
"Define which color iPhone to search for. Accepted options are: 'silver', 'gray'.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'storage',
|
||||||
|
type: String,
|
||||||
|
defaultValue: '256',
|
||||||
|
description: "Define which storage size to search for. Accepted options are: '64', '256'.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'zip',
|
||||||
|
type: String,
|
||||||
|
defaultOption: true,
|
||||||
|
description: 'Define the area to search in by zip code. This option is required.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'delay',
|
||||||
|
type: Number,
|
||||||
|
defaultValue: 30,
|
||||||
|
description: 'Define the number of seconds between requests.',
|
||||||
|
},
|
||||||
|
{ name: 'help', type: Boolean, description: 'Display this help screen.' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Parse command line args.
|
// Parse command line args.
|
||||||
@ -24,34 +57,36 @@ const options = commandLineArgs(optionDefinitions);
|
|||||||
const usageDefinition = [
|
const usageDefinition = [
|
||||||
{
|
{
|
||||||
header: 'iPhone X Availability Node CLI',
|
header: 'iPhone X Availability Node CLI',
|
||||||
content: "The app continously makes requests to Apple's availability api. When it finds some new stock near you, it displays the stores' name and distance from your zipcode then exits the program."
|
content:
|
||||||
|
"The app continously makes requests to Apple's availability api. When it finds some new stock near you, it displays the stores' name and distance from your zipcode then exits the program.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: 'Synopsis',
|
header: 'Synopsis',
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
desc: 'Default arguments.',
|
desc: 'Default arguments.',
|
||||||
example: '$ node index.js [bold]{--carrier} TMOBILE [bold]{--model} x [bold]{--color} gray [bold]{--storage} 256 [bold]{--delay} 30'
|
example:
|
||||||
|
'$ node index.js [bold]{--carrier} TMOBILE [bold]{--model} x [bold]{--color} gray [bold]{--storage} 256 [bold]{--delay} 30',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: 'Simple example',
|
desc: 'Simple example',
|
||||||
example: '$ node index.js [bold]{--zip} 10001 [bold]{--color} silver'
|
example: '$ node index.js [bold]{--zip} 10001 [bold]{--color} silver',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: 'Help screen.',
|
desc: 'Help screen.',
|
||||||
example: '$ node index.js [bold]{--help}'
|
example: '$ node index.js [bold]{--help}',
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: "Options",
|
header: 'Options',
|
||||||
optionList: optionDefinitions
|
optionList: optionDefinitions,
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
|
|
||||||
// if --help is present or --zip wasn't defined,
|
// if --help is present or --zip wasn't defined,
|
||||||
// then display the help screen and exit the program.
|
// then display the help screen and exit the program.
|
||||||
if (options['help'] || options['zip'] === undefined) {
|
if (options.help || options.zip === undefined) {
|
||||||
console.log(getUsage(usageDefinition));
|
console.log(getUsage(usageDefinition));
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user