Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
15342fc
Add: which subparser, Add: show subparser, Add: path filtering, Rewor…
rtmiz Jul 5, 2025
3cfa8a4
Restructure: filtering optional arguments, Add: scaffolding for snaps…
rtmiz Jul 5, 2025
966b139
Rudimentary implementation for undo/redo
rtmiz Jul 8, 2025
1c3b728
Add: better undo/redo functionality, Add: Rudimentary tests
rtmiz Jul 9, 2025
ae7be8f
Ignore __pycache__
rtmiz Jul 9, 2025
35a03ce
Ignore __pycache__
rtmiz Jul 9, 2025
48900ee
Ignore __pycache__
rtmiz Jul 9, 2025
6a76782
Merge branch 'main' into preset-global-updates
rtmiz Jul 9, 2025
2e56b51
Add: pre-commit checks
rtmiz Jul 9, 2025
ca34f29
Fix: pre-commit requirements for line length and f-strings
rtmiz Jul 9, 2025
04c1e97
Add: pytest-cov dependency
rtmiz Jul 9, 2025
d87ab5e
Remove: poetry.lock tracking
rtmiz Jul 9, 2025
777da7f
Add codecov
rtmiz Jul 9, 2025
bfbe5ee
Fix: test path
rtmiz Jul 9, 2025
a20397f
Fix: ignored test.txt
rtmiz Jul 9, 2025
d4ef04e
Add: Snapshot functionality, Rework: Generalize get value logic
rtmiz Jul 10, 2025
6633024
Add: small test changes
rtmiz Jul 10, 2025
4452767
Fix: occurence logic, Add: occurence tests
rtmiz Jul 15, 2025
c56d24f
Add: Tests for setting and filtering. Fix: bugs related to setting an…
rtmiz Jul 17, 2025
6dc2f9a
Add: verbosity tests
rtmiz Jul 17, 2025
7fc04f3
Add: preset-snapshot test, history test, update test. Rework: Update …
rtmiz Jul 22, 2025
fde728c
Add: history functionality for the rest of the commands, expand tests…
rtmiz Jul 22, 2025
4031770
Add: first mode, unfinished split mode. Rework: remove. Update: readme
rtmiz Jul 23, 2025
c43c193
Add: split and first mode, as well as tests for them
rtmiz Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions .github/workflows/commit-test.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: Run Unit Test via Pytest
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
name: Run Unit Test via Pytest

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
curl -sL https://install.python-poetry.org | python - -y

- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -47,10 +47,10 @@ jobs:
- name: Pre-commit hooks
run: poetry run pre-commit run --all-files

- name: Test with pytest
run: |
coverage run -m pytest -v -s
- name: Generate Coverage Report
run: |
coverage report -m
- name: Run pytest
run: poetry run pytest --cov --cov-branch --cov-report=xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.*
!.xet
!.pre-commit-config.yaml
**/__pycache__
poetry.lock
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
hooks:
- id: pyupgrade
args:
- --keep-runtime-typing
- --py39-plus

- repo: https://github.com/python-poetry/poetry
rev: 1.5.1
hooks:
- id: poetry-check

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.280"
hooks:
- id: ruff
16 changes: 8 additions & 8 deletions .xet
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"pyversion": {
"ppversion": {
"type": "tag",
"filepath": "xet/xet.py",
"flags": "ver",
"filepath": "pyproject.toml",
"flags": null,
"wrapper": "\"",
"presets": null,
"ssh": null,
"tag": "VERSION = ",
"tag": "version = ",
"occurences": ":",
"end": ""
},
"ppversion": {
"pyversion": {
"type": "tag",
"filepath": "pyproject.toml",
"flags": "ver",
"filepath": "xet/xet.py",
"flags": null,
"wrapper": "\"",
"presets": null,
"ssh": null,
"tag": "version = ",
"tag": "VERSION = ",
"occurences": ":",
"end": ""
}
Expand Down
140 changes: 118 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,37 @@
## Overview

xet is a command-line tool for managing and modifying values in multiple files using a configuration file (`.xet`). It supports various methods of identifying and modifying values, including tags, line/column positions, and regular expressions.
You can create presets and change between them on the fly.

## Installation


```sh
pip install xet
pipx install xet
```
or
```sh
pipx install xet
pip install xet
```


## Commands

### Initialize Configuration
### Configuration

#### Initialize Configuration

```sh
xet init
```
- Options:
- `-g, --global`: Global Mode. Creates a `.xet` file in the XDG_CONFIG_HOME folder instead of locally.
- `-g, --global`: Global Mode. Creates a `.xet` file in the XDG_CONFIG_HOME folder instead of locally.

Creates an empty `.xet` if it does not already exist.

Any xet command will use the `.xet` file in the immediate directory, unless the `-g, --global` flag is set, then the global `.xet` file will be used instead.
Any xet command will use the `.xet` file in the immediate directory, if there is no local `.xet` the global `.xet` file will be used instead. You can force the usage of the global `.xet` using the `-g, --global` flag.

#### Open .xet in editor

```sh
xet edit
Expand All @@ -41,10 +46,33 @@ xet edit

Opens `.xet` in your standard editor or nano.

#### Clarify .xet directory

```sh
xet which
```

### Add Entries to Configuration
Shows the absolute path to the default `.xet` that will be used if any xet command is run.

#### Add a Tag-Based Entry
#### Print .xet entries

```sh
xet show [options]
```

Options:
- `-e, --except <flags>`: Exclude entries with specified flags.
- `-o, --only <flags>`: Include only entries with specified flags.
- `-n, --names <names>`: Include only entries with specified names.
- `-p, --path <path>`: Include only entries with specified path.
- `-g, --global`: Use the global `.xet`.

Shows the `.xet` entries with the given optional filters applied.


#### Add Entries to Configuration

##### Add a Tag-Based Entry

```sh
xet add tag <name> <filepath> <tag> [options]
Expand All @@ -58,12 +86,12 @@ xet add tag <name> <filepath> <tag> [options]
- `-w, --wrapper <char>`: Wrap the value with a character (e.g., quotes), also gets stripped in get mode.
- `-o, --occurences <index or slice>`: Specify which occurrences to modify (string formatted like a list index in python, can be slices).
- `-e, --end <str>`: Will get appended in the line after value and wrappers, also gets stripped in get mode.
- `-p, --preset <str> <str>`: Name and value of preset, option can be repeated to add multiple presets.
- `-p, --preset <str> <str>`: Name and value of preset, option can be repeated to add multiple presets.
- `-s, --ssh <str>`: Hostname of ssh-host the file is found at, as found in openSSH config file.
- `-g, --global`: Add the entry to the global `.xet`.


#### Add a Line/Column-Based Entry
##### Add a Line/Column-Based Entry

```sh
xet add lc <name> <filepath> <line> <column> [options]
Expand All @@ -78,7 +106,7 @@ xet add lc <name> <filepath> <line> <column> [options]
- `-s, --ssh <str>`: Hostname of ssh-host the file is found at, as found in openSSH config file.
- `-g, --global`: Add the entry to the global `.xet`.

#### Add a Regex-Based Entry
##### Add a Regex-Based Entry

```sh
xet add regex <name> <filepath> <regex> [options]
Expand All @@ -94,32 +122,86 @@ xet add regex <name> <filepath> <regex> [options]
- `-s, --ssh <str>`: Hostname of ssh-host the file is found at, as found in openSSH config file.
- `-g, --global`: Add the entry to the global `.xet`.

### Get Values from Configured Files
#### Update Entries

```sh
xet update <key> <value> [options]
```
- `<key>`: The key of the property to update ('name' will update the key of the entry).
- `<value>`: The new value for the property.
Options:
- `-e, --except <flags>`: Exclude entries with specified flags.
- `-o, --only <flags>`: Include only entries with specified flags.
- `-n, --names <names>`: Include only entries with specified names.
- `-p, --path <path>`: Include only entries with specified path.
- `-g, --global`: Use the global `.xet`.

Updates the value of a property across filtered entries in the `.xet`.

#### Remove Entries

```sh
xet remove [options]
```

Options:
- `-e, --except <flags>`: Exclude entries with specified flags.
- `-o, --only <flags>`: Include only entries with specified flags.
- `-n, --names <names>`: Include only entries with specified names.
- `-p, --path <path>`: Include only entries with specified path.
- `-g, --global`: Use the global `.xet`.

Removes the specified entries from the `.xet`.

#### Snapshot

```sh
xet get [-e <flags>] [-o <flags>] [-n <names>]
xet snapshot <preset> [options]
```
- `<preset>`: The name of the new preset.
Options:
- `--first`: When there is divergent values in seperate occurences in an entry, use the first value for the preset.
- `--split`: When there is divergent values in seperate occurences in an entry, split the entry such that no divergences remain.
- `-e, --except <flags>`: Exclude entries with specified flags.
- `-o, --only <flags>`: Include only entries with specified flags.
- `-n, --names <names>`: Include only entries with specified names.
- `-p, --path <path>`: Include only entries with specified path.
- `-g, --global`: Use the global `.xet`.


Adds a preset to the filtered entries using their current values.

### Modifying Values

#### Get Values from Configured Files

```sh
xet get [options]
```

Options:
- `-e, --except <flags>`: Exclude entries with specified flags.
- `-o, --only <flags>`: Include only entries with specified flags.
- `-n, --names <names>`: Include only entries with specified names.
- `-p, --path <path>`: Include only entries with specified path.
- `-g, --global`: Use the global `.xet`.

### Set Values in Configured Files

#### Set Values in Configured Files

```sh
xet set <value> [-e <flags>] [-o <flags>] [-n <names>]
xet set <value> [options]
```

- `<value>`: The new value to be set.
Options:
- `-e, --except <flags>`: Exclude entries with specified flags.
- `-o, --only <flags>`: Include only entries with specified flags.
- `-n, --names <names>`: Include only entries with specified names.
- `-p, --path <path>`: Include only entries with specified path.
- `-g, --global`: Use the global `.xet`.

### Set Values to Preset
#### Set Values to Preset

```sh
xet preset <preset>
Expand All @@ -129,16 +211,31 @@ xet preset <preset>
- Options:
- `-g, --global`: Use the global `.xet`.

### Remove an Entry
### History

#### Undo

```sh
xet remove <name>
xet undo
```
- `<name>`: Name of the entry to be removed.
- Options:
- `-g, --global`: Remove the specified entry from the global `.xet`.

Removes the specified entry from `.xet` file.
Undoes the changes of the last command.

#### Redo

```sh
xet redo
```

Redoes the last undone changes.

#### Forget

```sh
xet forget
```

Reset history file.

## Example Usage

Expand Down Expand Up @@ -171,4 +268,3 @@ Removes the specified entry from `.xet` file.
```sh
xet remove version
```

Loading