Context Finder is simple and easy to use. It extracts contexts from (usually) configuration files. The main use case is extracting contexts from Asterisk configuration files.
Refer to the example here
Context Finder is available for NPM/Node and Deno.
You have a file that holds context blocks. That file might look like this:
[user-1]
name = Edward
language = en
[user-2]
name = John
language = us
[admin-1-1]
name = Admin Edward
[admin-1-2]
name = Admin John
[admin-2]
name = Admin
You want to extract all admin-1
contexts. In a single command you can pull that into a resulting file:
[admin-1-1]
name = Admin Edward
[admin-1-2]
name = Admin John
This is where Content Finder comes in.
If using NPM
apt install nodejs
apt install npm
If using Deno
Install the package from the NPM library
npm i --save context-finder
in your project root, or where your configuration files reside.
You will need to add node_modules
and package-lock.json
to your gitignore
file, then track package.json
Require the package
// my-node-script.js
const contextFinder = require('context-finder')
const contextsToFind = ['version-1.', 'version-4.']
const fileToRead = 'all-contexts.txt' // this file must exist
const fileToWrite = 'some-contexts.txt'
contextFinder(contextsToFind, fileToRead, fileToWrite)
cd ~/projects
git clone https://www.github.com/ebebbington/context-finder.git
npm i
node index.js <file to read> <file to write to> <context title 1> <context-title 2> ...
import { contextFinder } from "https://deno.land/x/context_finder/mod.ts";
const contextsToFind = ['version-1.', 'version-4.']
const fileToRead = 'all-contexts.txt' // this file must exist
const fileToWrite = 'some-contexts.txt'
contextFinder(contextsToFind, fileToRead, fileToWrite)
deno run --allow-read --allow-write https://deno.land/x/deno-context-finder@v1.0.1/mod.ts <file to read> <file to write to> <context title 1> <context-title 2> ...
Author: ebebbington
Source Code: https://github.com/ebebbington/context-finder
#deno #nodejs #node #javascript