-
Notifications
You must be signed in to change notification settings - Fork 0
/
findItem.js
30 lines (24 loc) · 839 Bytes
/
findItem.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
const { flags } = require('@oclif/command')
const Command = require('../lib/CommandLog')
const stdIn = require('../lib/stdin')
class FindItemCommand extends Command {
async run() {
const { flags, args } = this.parse(FindItemCommand)
let str = await stdIn()
if (str.isArray) {
let newArr = str.json.filter(item => {
// this.log(`looking for ${args.searchTerm} in ${item}`)
return item.indexOf(args.term) >= 0
})
this.log(newArr)
}else{
if(str.string.indexOf(args.term)) this.log(str.string)
}
}
}
FindItemCommand.args = [
{ name: 'term', required: true, description: 'The term to search for' }
]
FindItemCommand.aliases=['search','filter','find']
FindItemCommand.description = `Get an Item from an array, or a character from a string`
module.exports = FindItemCommand