https://github.com/ebebbington/context-finder
Search a given file for specific sections/context data, collect this and write to a new file. For Node and Deno.
https://github.com/ebebbington/context-finder
cli context-finder deno extracts-contexts nodejs
Last synced: 5 months ago
JSON representation
Search a given file for specific sections/context data, collect this and write to a new file. For Node and Deno.
- Host: GitHub
- URL: https://github.com/ebebbington/context-finder
- Owner: ebebbington
- License: mit
- Created: 2019-06-01T00:42:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-16T16:58:18.000Z (about 3 years ago)
- Last Synced: 2025-09-21T16:44:47.191Z (9 months ago)
- Topics: cli, context-finder, deno, extracts-contexts, nodejs
- Language: TypeScript
- Homepage:
- Size: 303 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
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](./example)
# Contents
- [Use Case](#use-case)
- [Requirements](#requirements)
- [A a Script](#as-a-script)
- [CLI](#cli)
- [Built With](#built-with)
- [License](#license)
# 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
```typescript
import { contextFinder } from "https://deno.land/x/context_finder@v1.1.1/mod.ts";
```
- Gather your data and run
```typescript
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 ...`
# Built With
- [Deno](https://deno.land) - Runtime Environment
# License
This project is licensed under the MIT License - see the
[LICENSE.txt](LICENSE.txt) file for details