Deno Context Finder
A Deno port of context-finder
A CLI scripting tool to extract context blocks from a configuration file.
- Deno version: v1.0.5
std
version: 0.56.0
Contents
Features
- Zero dependencies
- No installations required
- Can be used from the CLI or as an import
Use Case
Proves useful for extracting context blocks from Asterisk configuration files
You have .conf
file that holds context blocks for certain configurations. 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 create a new configuration file using some blocks from the above file. You might want to pull only admin
blocks, and if you are trying to be very specific, you might want to only pull admin-1*
blocks.
This is where Deno Content Finder comes in.
How it Works
Contexts are matched based on if the title contains the given parameters. This means that a single argument can match multiple context blocks, and will then write those collected to a file
Example
Passing in version-1.
as an argument will match version-1.
, version-1.1
, version-1.two
and so on.
Requirements
- Deno version 1.0.4
Usage
This module is available as a CLI tool or a dependency.
Dependency
Import the module into your
deps.ts
file:import { contextFinder } from "https://deno.land/x/deno-context-finder@v1.0.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' // does not need to exist, and will overwrite
contextFinder(contextsToFind, fileToRead, fileToWrite)
CLI
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> ...
Built With
- Deno - Runtime Environment