Skip to main content

Find and replace command line tool

Project description

# ctrshif

ctrshif stands for _ctrl+shift+f_ (find and replace)

## Usage

```plaintext
usage: ctrshif.py [-h] --section SECTION --values-file VALUES_FILE
(--template-file TEMPLATE_FILE | --template-list TEMPLATE_LIST)
[--prefix-delimiter PREFIX_DELIMITER]
[--suffix-delimiter SUFFIX_DELIMITER] [--no-delimiters]
[--dry-run]

optional arguments:
-h, --help show this help message and exit
--section SECTION the section of your .ini values file
--values-file VALUES_FILE
the location of your .ini values file
--template-file TEMPLATE_FILE
file which will be rendered
--template-list TEMPLATE_LIST
file containing a list of files which will be rendered
--prefix-delimiter PREFIX_DELIMITER
templating prefix delimiter, default: <%=
--suffix-delimiter SUFFIX_DELIMITER
templating suffix delimiter, default: %>
--no-delimiters no delimiters, only find and replace
--dry-run outputs in the terminal instead of writing to file
```

## Examples

Print to stdout (`--dry-run`) the replacement of all occurences found in `data.xml` with values from the section `[production]` within `values.ini`, delimiters are always assumed to be `<%=` and `%>` unless otherwise specified:
```bash
./ctrshif.py --section=production --values=values.ini --template=data.xml --dry-run
```

Replace (write to file) all occurences found in each file (separeted by line) from `list_of_files.txt` with values from section `[production]` within `values.ini`:
```bash
./ctrshif.py --section=production --values=values.ini --template-list=list_of_files.txt
```

Replace (write to file) all occurences found in `users.json` with values from section `[acceptance]` within `values.ini` surrounded by the delimiters `{{` and `}}`:
```bash
./ctrshif.py --section=acceptance --values=values.ini --template=users.json --prefix-delimiter="{{" --suffix-delimiter="}}"
```

Replace (write to file) all occurences found in `script.sh` with values from section `[default]` within `bash.ini`, without delimiters (word replacement):
```bash
./ctrshif.py --section=default --values=bash.ini --template=script.sh --no-delimiters
```

## Values file

The values file follow .ini format, and needs at least one section defined between brackets, ex: `[section]`.

```ini
[acceptance]
node_hostname = acc-foobar.org
node_ipaddr = 192.168.0
node_path = /var/log/syslog
node_timeout = 120

[development]
node_hostname = dev-foobar.org
node_ipaddr = 192.169.0
node_path = /var/log/syslog
node_timeout = 120
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctrshif-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctrshif-0.0.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file ctrshif-0.0.2.tar.gz.

File metadata

  • Download URL: ctrshif-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ctrshif-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e8cc2fe6e321b93969cf8045c5eb5e86eedd00103444caed28250ab29f44978b
MD5 e7b34677fb7878678a3b2eaef076d52c
BLAKE2b-256 bd05725cc4f9d767759d6a7b6f4e8f7c4f16bebd559e54a1581e462623b91856

See more details on using hashes here.

File details

Details for the file ctrshif-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ctrshif-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 364a42ea4ef4ac7be1b103e4c5e41b86cc2531c5f8064d84ffb7c0d8bc3ada24
MD5 1c403897cc16e3bfbdd181444c092734
BLAKE2b-256 a36084ee85b21af55535bec8877c34ec60cee6a168e7d5beefab8c0d6aeeb07d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page