Skip to content

Search a given file for specific sections/context data, collect this and write to a new file. For Node and Deno.

License

Notifications You must be signed in to change notification settings

ebebbington/context-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Context Finder

Context Finder


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

Contents

Use Case

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.

As a Script

  • Import the module
import { contextFinder } from "https://deno.land/x/context_finder@v1.1.1/mod.ts";
  • Gather your data and run
const contextsToFind = ["version-1.", "version-4."];
const fileToRead = "all-contexts.txt"; // this file must exist
const fileToWrite = "some-contexts.txt";

contextFinder(contextsToFind, fileToRead, fileToWrite);

CLI

deno run --allow-read --allow-write https://deno.land/x/context_finder@v1.1.1/mod.ts <file to read> <file to write to> <context title 1> <context-title 2> ...

Built With

  • Deno - Runtime Environment

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

About

Search a given file for specific sections/context data, collect this and write to a new file. For Node and Deno.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published