Skip to content

Commit 92d1390

Browse files
authored
Merge pull request #9 from machlit/tree
v1
2 parents 15936a2 + 00d0cb6 commit 92d1390

7 files changed

Lines changed: 20 additions & 118 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
build-arm64:
13+
ci:
1414
runs-on: macos-latest
1515

1616
env:
@@ -56,21 +56,20 @@ jobs:
5656
cp README.md release/
5757
cd release && zip -r ../${{ env.FILE_NAME }} bin man README.md LICENSE && cd ..
5858
59+
- name: Set release body
60+
id: release_body
61+
run: |
62+
body=$(cat RELEASE.md)
63+
echo "body<<EOF" >> $GITHUB_OUTPUT
64+
echo "$body" >> $GITHUB_OUTPUT
65+
echo "EOF" >> $GITHUB_OUTPUT
66+
5967
- name: Release
6068
uses: softprops/action-gh-release@v2
6169
with:
70+
body: ${{ steps.release_body.outputs.body }}
6271
files: ${{ env.FILE_NAME }}
6372

64-
publish:
65-
needs: [build-arm64]
66-
runs-on: macos-latest
67-
68-
env:
69-
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
70-
71-
steps:
72-
- uses: actions/checkout@v4
73-
7473
- name: Prepare Crates.io README
7574
run: sed -i '' '/^>/d' README.md
7675

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "defaults-rs"
3-
version = "0.7.1"
3+
version = "1.0.0"
44
edition = "2024"
55
authors = ["Machlit"]
66
description = "Open-source interface to a user's defaults on macOS"

RELEASE.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
## Bugs Fixed
1+
##
22

3-
- This release attempts to fix one of the bugs associated with some type changes in Rust v1.91, which fails to build the `plist` crate. defaults-rs depends on this crate for the import and export functionalities. This fix downgrades the version used from `v1.8.0` to `v1.7.4` which seems to work, for now.
4-
5-
---
6-
7-
The compressed binaries have been attached with the release.
3+
- This release stabilizes all of the internal APIs so that it's mature for a v1 release (yes, we're getting one right now!).
4+
- Removed the batch functions since more maturity in the concurrency part of the code is still needed. CoreFoundation bindings aren't by-default concurrent.

man/man1/drs.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.ie \n(.g .ds Aq \(aq
22
.el .ds Aq '
3-
.TH defaults-rs 1 "defaults-rs 0.7.0"
3+
.TH defaults-rs 1 "defaults-rs 1.0.0"
44
.SH NAME
55
defaults\-rs \- Open\-source interface to a user\*(Aqs defaults on macOS
66
.SH SYNOPSIS
@@ -46,4 +46,4 @@ Search all domains
4646
defaults\-rs\-help(1)
4747
Print this message or the help of the given subcommand(s)
4848
.SH VERSION
49-
v0.7.0
49+
v1.0.0

src/preferences/mod.rs

Lines changed: 2 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod types;
1212

1313
use anyhow::{Context, Result, bail};
1414
use std::{
15-
collections::{BTreeMap, HashMap},
15+
collections::BTreeMap,
1616
fs::{self, File},
1717
io::Cursor,
1818
path::PathBuf,
@@ -32,7 +32,7 @@ use crate::core::foundation;
3232
pub struct Preferences;
3333

3434
impl Preferences {
35-
/// List all available domains in ~/Library/Preferences.
35+
/// List all available domains.
3636
pub fn list_domains() -> Result<Vec<Domain>> {
3737
let list = foundation::list_domains()?;
3838

@@ -208,98 +208,4 @@ impl Preferences {
208208

209209
Ok(())
210210
}
211-
212-
/// Batch-write multiple key–value pairs for domains concurrently.
213-
///
214-
/// # Concurrency & Grouping
215-
/// - The input is a vector of tuples `(Domain, String, PrefValue)`.
216-
/// - All write requests are grouped by domain.
217-
///
218-
/// # Behavior
219-
/// - Only the designated keys are updated in each plist; the entire domain is not replaced.
220-
/// - For CoreFoundation domains, each key is written individually.
221-
///
222-
/// # Errors
223-
/// - If any write fails, the operation returns an error.
224-
pub fn write_batch(batch: Vec<(Domain, String, PrefValue)>) -> Result<()> {
225-
let mut groups: HashMap<Domain, Vec<(String, PrefValue)>> = HashMap::new();
226-
227-
// Group write requests by domain.
228-
for (domain, key, value) in batch {
229-
groups.entry(domain).or_default().push((key, value));
230-
}
231-
232-
for (domain, writes) in groups {
233-
let cf_name = &domain.get_cf_name();
234-
235-
for (key, value) in writes {
236-
foundation::write_pref(cf_name, &key, &value)?;
237-
}
238-
}
239-
240-
Ok(())
241-
}
242-
243-
/// Batch-read multiple keys for domains concurrently.
244-
///
245-
/// # Concurrency & Grouping
246-
/// - The input is a vector of tuples `(Domain, String)`.
247-
/// - Requests are grouped by domain.
248-
///
249-
/// # Behavior
250-
/// - The result is a vector of tuples `(Domain, String, ReadResult)`.
251-
///
252-
/// # Errors
253-
/// - If any read fails (e.g., key not found), the operation returns an error.
254-
pub fn read_batch(batch: Vec<(Domain, String)>) -> Result<Vec<(Domain, String, PrefValue)>> {
255-
let mut groups: HashMap<Domain, Vec<String>> = HashMap::new();
256-
257-
// group requests by domain
258-
for (domain, key) in batch {
259-
groups.entry(domain).or_default().push(key);
260-
}
261-
262-
let mut results = Vec::new();
263-
264-
for (domain, keys) in groups {
265-
let cf_name = &domain.get_cf_name();
266-
267-
for k in keys {
268-
let pref_val = foundation::read_pref(cf_name, &k)?;
269-
results.push((domain.clone(), k.clone(), pref_val));
270-
}
271-
}
272-
273-
Ok(results)
274-
}
275-
276-
/// Batch-delete multiple keys for domains concurrently.
277-
///
278-
/// # Concurrency & Grouping
279-
/// - The input is a vector of tuples `(Domain, String)`.
280-
/// - Requests are grouped by domain.
281-
///
282-
/// # Behavior
283-
/// - Only the specified keys are removed from the domain.
284-
///
285-
/// # Errors
286-
/// - If any deletion fails (e.g., key not found), the operation returns an error.
287-
pub fn delete_batch(batch: Vec<(Domain, String)>) -> Result<()> {
288-
let mut groups: HashMap<Domain, Vec<String>> = HashMap::new();
289-
290-
// group requests by domain
291-
for (domain, key) in batch {
292-
groups.entry(domain).or_default().push(key);
293-
}
294-
295-
for (domain, keys) in groups {
296-
let cf_name = &domain.get_cf_name();
297-
298-
for k in keys {
299-
foundation::delete_key(cf_name, &k)?
300-
}
301-
}
302-
303-
Ok(())
304-
}
305211
}

src/preferences/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::PrefValue;
77
pub enum Domain {
88
/// A user domain, e.g., "com.apple.finder"
99
User(String),
10-
/// The global preferences domain / NSGlobalDomain (".GlobalPreferences")
10+
/// The global preferences domain / NSGlobalDomain / .GlobalPreferences
1111
Global,
1212
}
1313

0 commit comments

Comments
 (0)