Skip to content

Commit badf320

Browse files
authored
Merge pull request #13 from GeraldIr/preset-global-updates
1.2.0
2 parents d31dd48 + c43c193 commit badf320

14 files changed

Lines changed: 2023 additions & 734 deletions

File tree

.github/workflows/commit-test.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
name: Run Unit Test via Pytest
2-
3-
on: [push]
4-
5-
jobs:
6-
build:
7-
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
python-version: ["3.10", "3.11", "3.12", "3.13"]
11-
12-
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v4
16-
with:
17-
python-version: ${{ matrix.python-version }}
18-
1+
name: Run Unit Test via Pytest
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.10", "3.11", "3.12", "3.13"]
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
1919
- name: Bootstrap poetry
2020
run: |
21-
curl -sL https://install.python-poetry.org | python - -y
21+
curl -sL https://install.python-poetry.org | python - -y
2222
2323
- name: Update PATH
2424
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
@@ -47,10 +47,10 @@ jobs:
4747
- name: Pre-commit hooks
4848
run: poetry run pre-commit run --all-files
4949

50-
- name: Test with pytest
51-
run: |
52-
coverage run -m pytest -v -s
53-
54-
- name: Generate Coverage Report
55-
run: |
56-
coverage report -m
50+
- name: Run pytest
51+
run: poetry run pytest --cov --cov-branch --cov-report=xml
52+
53+
- name: Upload coverage reports to Codecov
54+
uses: codecov/codecov-action@v5
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.*
2+
!.xet
3+
!.pre-commit-config.yaml
4+
**/__pycache__
5+
poetry.lock

.pre-commit-config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v3.9.0
4+
hooks:
5+
- id: pyupgrade
6+
args:
7+
- --keep-runtime-typing
8+
- --py39-plus
9+
10+
- repo: https://github.com/python-poetry/poetry
11+
rev: 1.5.1
12+
hooks:
13+
- id: poetry-check
14+
15+
- repo: https://github.com/pycqa/isort
16+
rev: 5.12.0
17+
hooks:
18+
- id: isort
19+
name: isort (python)
20+
args: ["--profile", "black"]
21+
22+
- repo: https://github.com/pre-commit/pre-commit-hooks
23+
rev: v4.4.0
24+
hooks:
25+
- id: trailing-whitespace
26+
- id: end-of-file-fixer
27+
- id: check-yaml
28+
29+
- repo: https://github.com/psf/black
30+
rev: 23.7.0
31+
hooks:
32+
- id: black
33+
34+
- repo: https://github.com/charliermarsh/ruff-pre-commit
35+
rev: "v0.0.280"
36+
hooks:
37+
- id: ruff

.xet

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"pyversion": {
2+
"ppversion": {
33
"type": "tag",
4-
"filepath": "xet/xet.py",
5-
"flags": "ver",
4+
"filepath": "pyproject.toml",
5+
"flags": null,
66
"wrapper": "\"",
77
"presets": null,
88
"ssh": null,
9-
"tag": "VERSION = ",
9+
"tag": "version = ",
1010
"occurences": ":",
1111
"end": ""
1212
},
13-
"ppversion": {
13+
"pyversion": {
1414
"type": "tag",
15-
"filepath": "pyproject.toml",
16-
"flags": "ver",
15+
"filepath": "xet/xet.py",
16+
"flags": null,
1717
"wrapper": "\"",
1818
"presets": null,
1919
"ssh": null,
20-
"tag": "version = ",
20+
"tag": "VERSION = ",
2121
"occurences": ":",
2222
"end": ""
2323
}

README.md

Lines changed: 118 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,37 @@
77
## Overview
88

99
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.
10+
You can create presets and change between them on the fly.
1011

1112
## Installation
1213

1314

1415
```sh
15-
pip install xet
16+
pipx install xet
1617
```
1718
or
1819
```sh
19-
pipx install xet
20+
pip install xet
2021
```
2122

2223

2324
## Commands
2425

25-
### Initialize Configuration
26+
### Configuration
27+
28+
#### Initialize Configuration
2629

2730
```sh
2831
xet init
2932
```
3033
- Options:
31-
- `-g, --global`: Global Mode. Creates a `.xet` file in the XDG_CONFIG_HOME folder instead of locally.
34+
- `-g, --global`: Global Mode. Creates a `.xet` file in the XDG_CONFIG_HOME folder instead of locally.
3235

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

35-
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.
38+
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.
39+
40+
#### Open .xet in editor
3641

3742
```sh
3843
xet edit
@@ -42,10 +47,33 @@ xet edit
4247

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

50+
#### Clarify .xet directory
51+
52+
```sh
53+
xet which
54+
```
4555

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

48-
#### Add a Tag-Based Entry
58+
#### Print .xet entries
59+
60+
```sh
61+
xet show [options]
62+
```
63+
64+
Options:
65+
- `-e, --except <flags>`: Exclude entries with specified flags.
66+
- `-o, --only <flags>`: Include only entries with specified flags.
67+
- `-n, --names <names>`: Include only entries with specified names.
68+
- `-p, --path <path>`: Include only entries with specified path.
69+
- `-g, --global`: Use the global `.xet`.
70+
71+
Shows the `.xet` entries with the given optional filters applied.
72+
73+
74+
#### Add Entries to Configuration
75+
76+
##### Add a Tag-Based Entry
4977

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

6694

67-
#### Add a Line/Column-Based Entry
95+
##### Add a Line/Column-Based Entry
6896

6997
```sh
7098
xet add lc <name> <filepath> <line> <column> [options]
@@ -79,7 +107,7 @@ xet add lc <name> <filepath> <line> <column> [options]
79107
- `-s, --ssh <str>`: Hostname of ssh-host the file is found at, as found in openSSH config file.
80108
- `-g, --global`: Add the entry to the global `.xet`.
81109

82-
#### Add a Regex-Based Entry
110+
##### Add a Regex-Based Entry
83111

84112
```sh
85113
xet add regex <name> <filepath> <regex> [options]
@@ -95,32 +123,86 @@ xet add regex <name> <filepath> <regex> [options]
95123
- `-s, --ssh <str>`: Hostname of ssh-host the file is found at, as found in openSSH config file.
96124
- `-g, --global`: Add the entry to the global `.xet`.
97125

98-
### Get Values from Configured Files
126+
#### Update Entries
127+
128+
```sh
129+
xet update <key> <value> [options]
130+
```
131+
- `<key>`: The key of the property to update ('name' will update the key of the entry).
132+
- `<value>`: The new value for the property.
133+
Options:
134+
- `-e, --except <flags>`: Exclude entries with specified flags.
135+
- `-o, --only <flags>`: Include only entries with specified flags.
136+
- `-n, --names <names>`: Include only entries with specified names.
137+
- `-p, --path <path>`: Include only entries with specified path.
138+
- `-g, --global`: Use the global `.xet`.
139+
140+
Updates the value of a property across filtered entries in the `.xet`.
141+
142+
#### Remove Entries
143+
144+
```sh
145+
xet remove [options]
146+
```
147+
148+
Options:
149+
- `-e, --except <flags>`: Exclude entries with specified flags.
150+
- `-o, --only <flags>`: Include only entries with specified flags.
151+
- `-n, --names <names>`: Include only entries with specified names.
152+
- `-p, --path <path>`: Include only entries with specified path.
153+
- `-g, --global`: Use the global `.xet`.
154+
155+
Removes the specified entries from the `.xet`.
156+
157+
#### Snapshot
99158

100159
```sh
101-
xet get [-e <flags>] [-o <flags>] [-n <names>]
160+
xet snapshot <preset> [options]
161+
```
162+
- `<preset>`: The name of the new preset.
163+
Options:
164+
- `--first`: When there is divergent values in seperate occurences in an entry, use the first value for the preset.
165+
- `--split`: When there is divergent values in seperate occurences in an entry, split the entry such that no divergences remain.
166+
- `-e, --except <flags>`: Exclude entries with specified flags.
167+
- `-o, --only <flags>`: Include only entries with specified flags.
168+
- `-n, --names <names>`: Include only entries with specified names.
169+
- `-p, --path <path>`: Include only entries with specified path.
170+
- `-g, --global`: Use the global `.xet`.
171+
172+
173+
Adds a preset to the filtered entries using their current values.
174+
175+
### Modifying Values
176+
177+
#### Get Values from Configured Files
178+
179+
```sh
180+
xet get [options]
102181
```
103182

104183
Options:
105184
- `-e, --except <flags>`: Exclude entries with specified flags.
106185
- `-o, --only <flags>`: Include only entries with specified flags.
107186
- `-n, --names <names>`: Include only entries with specified names.
187+
- `-p, --path <path>`: Include only entries with specified path.
108188
- `-g, --global`: Use the global `.xet`.
109189

110-
### Set Values in Configured Files
190+
191+
#### Set Values in Configured Files
111192

112193
```sh
113-
xet set <value> [-e <flags>] [-o <flags>] [-n <names>]
194+
xet set <value> [options]
114195
```
115196

116197
- `<value>`: The new value to be set.
117198
Options:
118199
- `-e, --except <flags>`: Exclude entries with specified flags.
119200
- `-o, --only <flags>`: Include only entries with specified flags.
120201
- `-n, --names <names>`: Include only entries with specified names.
202+
- `-p, --path <path>`: Include only entries with specified path.
121203
- `-g, --global`: Use the global `.xet`.
122204

123-
### Set Values to Preset
205+
#### Set Values to Preset
124206

125207
```sh
126208
xet preset <preset>
@@ -130,16 +212,31 @@ xet preset <preset>
130212
- Options:
131213
- `-g, --global`: Use the global `.xet`.
132214

133-
### Remove an Entry
215+
### History
216+
217+
#### Undo
134218

135219
```sh
136-
xet remove <name>
220+
xet undo
137221
```
138-
- `<name>`: Name of the entry to be removed.
139-
- Options:
140-
- `-g, --global`: Remove the specified entry from the global `.xet`.
141222

142-
Removes the specified entry from `.xet` file.
223+
Undoes the changes of the last command.
224+
225+
#### Redo
226+
227+
```sh
228+
xet redo
229+
```
230+
231+
Redoes the last undone changes.
232+
233+
#### Forget
234+
235+
```sh
236+
xet forget
237+
```
238+
239+
Reset history file.
143240

144241
## Example Usage
145242

@@ -172,4 +269,3 @@ Removes the specified entry from `.xet` file.
172269
```sh
173270
xet remove version
174271
```
175-

0 commit comments

Comments
 (0)